Back to Blog

Deploy an MCP Tool for Claude Desktop in 60 Seconds

MCP (Model Context Protocol) lets AI assistants like Claude call external tools — functions you write that run on demand. Instead of copy-pasting data into a chat window, you give the AI a URL and it calls your code directly.

fold.run makes deploying MCP tools trivial. Write a function, deploy it, and point Claude Desktop at the endpoint. The whole process takes about a minute.

Prerequisites

You need Node.js 18+ installed. Then install the fold CLI:

npm i -g @fold-run/cli

Step 1: Log in

Authenticate with your fold.run account:

fold login

This opens a browser window. Log in and the CLI stores your credentials locally.

Step 2: Create a tool

Scaffold a new project:

fold init word-counter --yes

This creates a word-counter/ directory with a single index.ts file and a fold.json config. The --yes flag accepts all defaults.

Open word-counter/index.ts. You will see a starter template:

import { defineHandler } from "@fold-run/runtime";

export default defineHandler(async (fold) => {
  const body = await fold.body();
  return fold.json({ message: "Hello from fold.run", input: body });
});

Step 3: Build something useful

Replace the contents of index.ts with a word counter tool. This analyzes text and returns word count, character count, sentence count, and estimated reading time:

import { defineHandler } from "@fold-run/runtime";

export default defineHandler(async (fold) => {
  const { text } = await fold.body<{ text: string }>();

  if (!text || typeof text !== "string") {
    return fold.json({ error: "Provide a 'text' field" }, 400);
  }

  const words = text.trim().split(/\s+/).filter(Boolean);
  const sentences = text.split(/[.!?]+/).filter((s) => s.trim().length > 0);
  const readingTimeMinutes = Math.ceil(words.length / 200);

  return fold.json({
    wordCount: words.length,
    characterCount: text.length,
    sentenceCount: sentences.length,
    readingTimeMinutes,
    averageWordLength: words.length
      ? +(words.reduce((sum, w) => sum + w.length, 0) / words.length).toFixed(1)
      : 0,
  });
});

The function receives a JSON body with a text field, analyzes it, and returns structured results. Any MCP-compatible client can call this automatically.

Step 4: Deploy

From the word-counter/ directory:

fold deploy

The CLI bundles your code and deploys it. You will see output like:

Deployed word-counter v1
  URL: https://your-org.fold.run/word-counter
  MCP: https://your-org.fold.run/.well-known/mcp

The MCP endpoint is the URL you need for Claude Desktop. It serves all your deployed tools as MCP-compatible resources.

Step 5: Connect Claude Desktop

Open your Claude Desktop configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json

Add your fold.run MCP endpoint:

{
  "mcpServers": {
    "fold": {
      "url": "https://your-org.fold.run/.well-known/mcp"
    }
  }
}

Replace your-org with your actual organization slug. Save the file and restart Claude Desktop.

Step 6: Test it

Open Claude Desktop and try a prompt like:

"Use the word-counter tool to analyze this paragraph: The quick brown fox jumps over the lazy dog. This sentence has exactly nine words."

Claude will call your deployed function and return the analysis. You can see each invocation in the fold.run dashboard under Logs.

What just happened

You wrote a TypeScript function, deployed it to a globally distributed runtime, and made it available as an MCP tool — all without provisioning servers, configuring domains, or writing API specs.

Every function you deploy to fold.run is automatically available through the MCP endpoint. Deploy five functions, and Claude Desktop sees five tools.

Next steps

  • Add more tools: Create functions for any task — data lookups, calculations, API integrations, content generation. Each one becomes an MCP tool automatically.
  • Attach bindings: Connect key-value storage, databases, or AI models to your functions. See the Bindings docs for details.
  • Try Fold Agent: Build a personal AI assistant with memory, knowledge, and multi-channel messaging at agent.fold.run.
  • Chain tools into pipelines: Compose multiple tools into sequential workflows. The output of one tool feeds into the next. See Pipelines.