Skip to content

Instantly share code, notes, and snippets.

@RafalWilinski
RafalWilinski / claude-desktop-auto-allow-everything-mcp.js
Last active April 23, 2025 12:41
Auto-approve all MCP tool calls in Claude Desktop
// HOW TO INSTRUCTIONS
// 1. Open Claude Desktop
// 2. Go to Help -> Enable Developer Mode
// 3. Navigate Developer Tools window named "Developer Tools - https://claude.ai"
// 4. Go to "Console" tab
// 5. Type "allow pasting" and hit Enter
// 6. Paste this snippet and hit Enter
// From now on, all MCP calls will be auto-approved
import { initLogger, wrapAISDKModel, traced } from "braintrust";
import { createGoogleGenerativeAI } from "@ai-sdk/google";
import { generateText } from "ai";
export type GoogleGenerativeAI =
| "gemini-2.0-pro-exp-02-05"
| "gemini-2.0-flash";
export const initBraintrust = (braintrustApiKey: string) => {
const logger = initLogger({
@RafalWilinski
RafalWilinski / vectorize_problem.ts
Created February 4, 2025 16:52
This fails on query but works on describe. Why?
import { getPlatformProxy } from "wrangler";
(async () => {
const proxy = await getPlatformProxy<Env>();
/// This succeeds!
const vectorizeIndex = await proxy.env.VECTORIZE_INDEX.describe();
console.log(vectorizeIndex);
const vector = new Array(1024).fill(0);
@RafalWilinski
RafalWilinski / gac.sh
Created December 7, 2024 12:27
Generating commit messages using `llm` CLI in command line
# Function to generate commit message using LLM
generate_commit() {
git add .
# Get the staged changes
DIFF=$(git diff --cached)
if [ -z "$DIFF" ]; then
echo "No staged changes found. Please stage your changes first using 'git add'"
return 1
fi
export const onRequest: PagesFunction<Env> = async (ctx) => {
const stream = await ctx.env.AI.run("@hf/nousresearch/hermes-2-pro-mistral-7b", {
messages: [
{
role: "user",
content: "What is the capital of the moon?",
},
],
stream: true,
});
[gpt-4o-mini-non-strict-tool (Complex JSON Schema)] Run 1 failed
[gpt-4o-mini-non-strict-json (Wide JSON Schema)] Run 1: 3147.1813 ms
[gpt-4o-2024-08-06-non-strict-tool (Wide JSON Schema)] Run 1: 3418.5543 ms
[gpt-4o-mini-non-strict-tool (Wide JSON Schema)] Run 1: 3418.7064 ms
[gpt-4o-2024-08-06-non-strict-json (Wide JSON Schema)] Run 1: 4436.7569 ms
[gpt-4o-2024-08-06-non-strict-tool (Complex JSON Schema)] Run 1: 4677.3473 ms
[gpt-4o-mini-non-strict-tool (Wide JSON Schema)] Run 2: 2659.2542 ms
[gpt-4o-mini-non-strict-tool (Complex JSON Schema)] Run 2 failed
[gpt-4o-2024-08-06-non-strict-tool (Wide JSON Schema)] Run 2: 2807.2270 ms
[gpt-4o-2024-08-06-non-strict-json (Complex JSON Schema)] Run 1: 7188.8446 ms
const awsTool = new DynamicTool({
name: "aws-cli",
description:
"This is AWS CLI. You can call this to send commands to the AWS Cloud. Use AWS CLI format like `aws s3api list-buckets`",
async func(command) {
const args = command.split(" ").filter((x) => x !== "aws");
const result = spawnSync("aws", args, {
env: {
...process.env,
AWS_REGION: "eu-central-1",
// First, get the item
DynamoDB.get({
TableName: "http-crud-tutorial-items",
Key: {
id: "1",
},
}).promise().then((data) => {
const item = data.Item;
// Update the item
@RafalWilinski
RafalWilinski / AWS Marketplace Contract Flow.md
Created April 16, 2022 15:08
Visual diagram of How AWS Marketplace fit into your Monthly/Annual subscriptions model
sequenceDiagram
  participant User
  participant AWS Marketplace Product Page
  participant Your Marketplace Landing Form
  participant Your subscriptions API
  participant AWS Marketplace Metering Service

  User ->> AWS Marketplace Product Page: Visits
   User ->> AWS Marketplace Product Page: Purchases contract/subscription
name: Build/release
on:
release:
types: # This configuration does not affect the page_build event above
- created
jobs:
release:
runs-on: ${{ matrix.os }}