Logo vun CodeMesh MCP Server

CodeMesh MCP Server

Communautéit
kiliman

The Self-Improving MCP Server - Agents write code to orchestrate multiple MCP servers with intelligent TypeScript execution and auto-augmentation

Editeurkiliman
Repositorycodemesh
SproochTypeScript
Forks
4
Stären
26
Disponibel Tools
5
Transporttypstdio
Kategorien
LizenzMIT
Linken
  • Tools mat KI-Workflows verbannen

    CodeMesh MCP Server stellt MCP-Funktioune bereit, déi vu kompatibele KI-Clienten a KI-Agente kënne benotzt ginn.

  • 5 disponibel Tools

    Kuckt Iech déi opruffbar Aktiounen hei drënner un, mat Nimm a Beschreiwungen, wa se vum Server geliwwert ginn.

  • Konfiguratioun fir ze kopéieren

    Benotzt d'Installatiounsbeispiller, fir dëse Server an Ärem bevorzugte MCP-Client ze konfiguréieren.

  • Indicateure fir Open Source

    26 Stären an 4 Forks aus dem verlinkte Repository.

📺 See It In Action

CodeMesh Demo

Watch: How Agent A explores and documents, then Agent B one-shots the same task - 2.6x faster!

📖 Read the story: Building CodeMesh - From Idea to Self-Improving Intelligence

What is CodeMesh?

CodeMesh lets AI agents write TypeScript code to orchestrate ANY MCP server. One prompt. One code block. Multiple servers working together.

Instead of exposing dozens of individual tools, CodeMesh provides just 3 tools:

  1. discover-tools - See what's available (context-efficient overview)
  2. get-tool-apis - Get TypeScript APIs for specific tools
  3. execute-code - Execute TypeScript that calls multiple tools

🎉 The Innovation: Auto-Augmentation

When agents encounter unclear tool outputs, CodeMesh forces documentation before proceeding. This creates compound intelligence - each exploration helps ALL future agents.

Proven: Agent A explored and documented. Agent B one-shot the same task. 2.6x faster! 🚀

Installation

1. Add CodeMesh to Claude Desktop

bash
claude mcp add codemesh npx -y codemesh

Or manually add to your Claude Desktop MCP settings:

json
{
  "mcpServers": {
    "codemesh": {
      "command": "npx",
      "args": ["-y", "codemesh"]
    }
  }
}

2. Create Configuration

Create a .codemesh/config.json file in your project directory to configure which MCP servers CodeMesh should connect to:

json
{
  "logging": {
    "enabled": true,
    "level": "info",
    "logDir": ".codemesh/logs"
  },
  "servers": [
    {
      "id": "filesystem",
      "name": "File System",
      "type": "stdio",
      "command": ["npx", "@modelcontextprotocol/server-filesystem", "/path/to/directory"],
      "timeout": 30000
    },
    {
      "id": "brave-search",
      "name": "Brave Search",
      "type": "stdio",
      "command": ["npx", "-y", "@modelcontextprotocol/server-brave-search"],
      "env": {
        "BRAVE_API_KEY": "${BRAVE_API_KEY}"
      }
    },
    {
      "id": "weather",
      "name": "Weather Server",
      "type": "http",
      "url": "http://localhost:3000/mcp"
    }
  ]
}

Server Configuration Options

Each server entry supports:

  • id (required) - Unique identifier for the server
  • name (required) - Human-readable name
  • type (required) - Server type: "stdio", "http", or "websocket"
  • command (stdio only) - Command array to start the server
  • cwd (stdio only) - Working directory for the command
  • url (http/websocket only) - Server URL
  • env (optional) - Environment variables for the server
  • timeout (optional) - Connection timeout in milliseconds

Environment Variable Substitution

Use ${VAR} or ${VAR:-default} syntax in your config for secure credential management:

json
{
  "env": {
    "API_KEY": "${MY_API_KEY}",
    "ENDPOINT": "${API_ENDPOINT:-https://default.api.com}"
  }
}

This works with any environment variable manager (Doppler, 1Password, etc.) and keeps your config safe to commit.

Logging Configuration

Enable markdown-based file logging to track tool calls, code execution, and responses:

json
{
  "logging": {
    "enabled": true,
    "level": "info",
    "logDir": ".codemesh/logs"
  }
}

Options:

  • enabled (boolean) - Enable/disable file logging
  • level ("debug" | "info" | "warn" | "error") - Minimum log level to record
  • logDir (string) - Directory for log files (defaults to .codemesh/logs)

Log Format:

Logs are saved as markdown files (.codemesh/logs/YYYY-MM-DD.md) with syntax highlighting:

markdown
## 14:52:45 - execute-code

**Duration:** 2.1s
**Status:** ✅ Success

### Request

` ``typescript
const alerts = await weatherServer.getAlerts({ state: 'CA' })
return alerts ` ``

### Console Output

` ``
Found 3 alerts ` ``

### Response

` ``json
{ "count": 3, "alerts": [...] } ` ``

Perfect for debugging, demo preparation, and understanding what CodeMesh is doing! 🎯

How It Works

CodeMesh uses an intelligent three-step workflow that happens automatically when you give it a prompt:

Example: Real-World Usage

You ask Claude:

"Use CodeMesh to give me the top 3 weather alerts for Moyock, NC"

Behind the scenes, CodeMesh automatically:

  1. Discovers Tools (discover-tools)

    • Sees geocode tool (to convert "Moyock, NC" to coordinates)
    • Sees getAlerts tool from weather server
    • Context-efficient: only shows tool names and descriptions
  2. Loads APIs (get-tool-apis)

    • Requests TypeScript function signatures for geocode and getAlerts
    • Generates type-safe APIs: geocodeServer.geocode({ location }) and weatherServer.getAlerts({ state })
    • Includes any existing augmentation documentation from previous runs
  3. Writes & Executes Code (execute-code)

    • CodeMesh writes TypeScript code that:
      • Calls geocodeServer.geocode to get coordinates
      • Calls weatherServer.getAlerts with the state
      • Parses results and filters to top 3 by severity
    • Executes in secure VM2 sandbox (30s timeout)
    • Returns formatted results

Self-Improving Intelligence (Auto-Augmentation)

The Problem: Most MCP servers don't document their output formats. Is it JSON? Plain text? Key-value pairs? Arrays?

CodeMesh's Solution: When the agent struggles to parse output, it automatically:

  1. Enters EXPLORATION Mode

    • Adds // EXPLORING comment to the code
    • Calls the tool to examine actual output structure
    • Figures out: Is it JSON? What fields exist? What's the structure?
  2. Gets Blocked by Design

    • CodeMesh returns an ERROR (not success) for exploration mode
    • Forces the agent to document before proceeding
    • "You cannot parse until you create augmentation!"
  3. Creates Augmentation (add-augmentation)

    • Agent writes markdown documentation with:
      • Output format description
      • Field definitions
      • Example output (actual data from exploration)
      • Working parsing code (TypeScript examples)
    • Saves to .codemesh/[server-id].md
  4. Enhanced for Next Time

    • Next get-tool-apis call includes augmentation in JSDoc
    • Future agents see the parsing examples and data structure
    • One-shot success - no trial-and-error needed!

Result: Agent A struggles and documents. Agent B one-shots it. Agent C one-shots it. Compound intelligence!

Example: What CodeMesh Writes For You

Your prompt:

"Find the 3 most severe weather alerts in North Carolina"

CodeMesh automatically writes:

typescript
// Step 1: Fetch weather alerts
const alerts = await weatherServer.getAlerts({ state: 'NC' })
const alertsData = JSON.parse(alerts.content[0].text)

// Step 2: Define severity hierarchy
const severityHierarchy = ['Extreme', 'Severe', 'Moderate', 'Minor']
const highestSeverity = severityHierarchy.find((severity) =>
  alertsData.features.some((alert) => alert.properties.severity === severity),
)

// Step 3: Filter and return top 3
const topAlerts = alertsData.features.filter((alert) => alert.properties.severity === highestSeverity).slice(0, 3)

return {
  count: topAlerts.length,
  severity: highestSeverity,
  alerts: topAlerts,
}

You get intelligent results - no manual tool calls, no trial-and-error, just results!

Why CodeMesh?

❌ The Problem

  • Traditional MCP: Expose 50+ tools, flood agent context
  • Agents can't coordinate tools from different servers
  • Trial-and-error on unclear tool outputs wastes tokens
  • Every agent repeats the same mistakes

✨ The CodeMesh Way

  • Just 3 tools: discover, get APIs, execute code
  • Agents write TypeScript calling multiple servers at once
  • Auto-augmentation forces documentation of outputs
  • Knowledge compounds: Agent A helps Agent B

🏆 Key Features

  • 🧠 Self-Improving - Agents document unclear outputs, future agents benefit
  • 🔗 Multi-Server Orchestration - Coordinate tools from different MCP servers in single code block (HTTP + stdio + websocket)
  • 🎯 Context Efficient - Load only the tools you need, 3 tools vs 50+
  • 🚀 Zero Configuration - Point to your MCP servers and go, works with ANY compliant MCP server
  • ⚡ Production Ready - Type-safe TypeScript execution in VM2 sandbox, authentication, error handling
  • 🔒 Secure by Default - Environment variable substitution, principle of least privilege

Best Practices

Use Subagents for Maximum Context Efficiency

While CodeMesh is context-efficient internally (tiered discovery prevents tool pollution), we strongly recommend spawning a subagent to execute CodeMesh operations. This keeps your main agent's context clean while CodeMesh does the heavy lifting.

Example with Claude Code:

User: "Analyze the weather data and file structure for my project"
Main Agent: Let me spawn a subagent to handle this task...

Main agent uses the Task tool to spawn a codemesh subagent with the prompt: "Use CodeMesh to analyze weather alerts for NC and correlate with local file timestamps"

Benefits:

  • 🧹 Main context stays clean
  • ⚡ Subagent can iterate on CodeMesh without polluting parent
  • 🎯 Specialized subagent focused solely on orchestration
  • 📦 Results summarized back to main agent when complete

When NOT to use subagents:

  • Simple single-tool calls (just use the tool directly)
  • When you need tight integration with main conversation flow

See examples/codemesh-agent.md for a ready-to-use Claude Code agent configuration.

Contributing

Want to contribute to CodeMesh development? See CONTRIBUTING.md for developer setup, architecture details, and development workflows.


Built with Sonnet 4.5

From Claudia, with Love ❤️

Built with Claude Code using Sonnet 4.5 for the Anthropic MCP Hackathon

🌐 Website • 📖 Blog • 📦 NPM • 📺 Demo Video

Installatioun

TypingMind
{
  "mcpServers": {
    "codemesh": {
      "command": "npx",
      "args": [
        "-y",
        "codemesh"
      ]
    }
  }
}

Disponibel Tools

  • execute-code

    CODEMESH STEP 3: Execute TypeScript code that can call multiple MCP tools and process their results.

    <augmentation_instruction> IMPORTANT: When exploring tool output, add a comment explaining what you're checking: // EXPLORING: checking output format of filesystemServer.getFileInfo const result = await filesystemServer.getFileInfo({path: 'test.txt'}); console.log(result);

    This triggers augmentation guidance in the response. </augmentation_instruction>

    <augmentation_workflow> If tool output is unclear/hard to parse, DO NOT trial-and-error different parsing approaches!

    REQUIRED WORKFLOW:

    1. Inspect raw output with console.log (include // EXPLORING comment)
    2. When you see unclear output, STOP and create augmentation markdown:

    serverName.met

  • discover-tools

    CODEMESH STEP 1: Discover available tools from configured MCP servers. Use this first to see what tools are available before writing code. This is the preferred approach for complex tasks that require multiple tool calls or data processing across different MCP servers.

  • generate-types

    CODEMESH OPTIONAL: Generate complete TypeScript type definitions for all discovered MCP tools. Prefer get-tool-apis for context efficiency unless you need all types.

  • add-augmentation

    Save or update augmentation documentation for an MCP tool. Augmentations provide detailed output format descriptions, parsing examples, and field documentation that enhance the TypeScript APIs generated by get-tool-apis. The markdown will be saved to .codemesh/{serverId}.md and future get-tool-apis calls will include this documentation in the JSDoc.

  • get-tool-apis

    CODEMESH STEP 2: Get TypeScript type definitions for specific tools you want to use in your code. This generates the server object interfaces you'll need. Use this after discover-tools to get only the APIs you need. IMPORTANT: Tools are available as server objects with methods, NOT as direct functions. Use the format: await serverName.methodName() (e.g., await weatherServer.getForecast(), await geocodeServer.geocode()). Do NOT use direct function calls like geocode() or get_forecast().

CodeMesh MCP Server MCP mat verschiddene KI-Modeller benotzen

TypingMind verbënnt MCP-Tools um Niveau vum Aarbechtsberäich. Soubal CodeMesh MCP Server verbonnen ass, kënnt Dir et mat verschiddene KI-Modeller an TypingMind benotzen, amplaz et fir all Modell separat anzeriichten. Dës MCP-Integratioun leeft lokal iwwer den TypingMind-MCP-Connector op Ärem Apparat.

Ariichtungsuleedung fir de lokale Connector ze benotzen

Benotzt dës Optioun, wann den MCP-Server Zougrëff op lokal Fichieren, Appen oder privat Ressourcen op Ärem Computer brauch.

1

D'MCP-Astellungen opmaachen

Gitt an TypingMind op „Astellungen“, „Erweidert Astellungen“, dann op „Model Context Protocol“ a wielt „Connector ariichten“.

  1. Maacht TypingMind an Ärem Browser op.
  2. Klickt op d'Astellungssymbol.
  3. Gitt op „Erweidert Astellungen“.
  4. Maacht d'Sektioun „Model Context Protocol“ op.
  5. Klickt op „Connector ariichten“ a wielt „Dësen Apparat“.
Ariichtungsbildschierm vum TypingMind-MCP-Connector mat „Dësen Apparat“ ausgewielt
2

De Connector-Befeel ausféieren

Wielt „Dësen Apparat“, kopéiert de Befeel aus TypingMind a féiert en am Terminal aus. Loosst de Prozess lafen, wärend Dir MCP benotzt.

  1. Kopéiert den Ariichtungsbefeel, deen TypingMind uweist.
  2. Maacht Terminal op macOS oder Windows Terminal op Windows op.
  3. Pescht de Befeel an a féiert en aus.
  4. Bestätegt d'Installatioun vum Package, wann den Terminal Iech freet, ob Dir weiderfuere wëllt.
  5. Loosst den Terminal an de Prozess doranner lafen, wärend Dir MCP-Tools benotzt.
3

CodeMesh MCP Server als Server derbäisetzen

Wann de Connector-Status „Prett“ ass, klickt op „Serveren änneren“ a pescht d'MCP-Serverkonfiguratioun an.

  1. Waart, bis de Connector-Status „Prett“ weist.
  2. Klickt op „Serveren änneren“.
  3. Pescht d'MCP-Serverkonfiguratioun vu CodeMesh MCP Server an.
  4. Späichert d'Serverlëscht.
  5. Aktualiséiert, wann Dir kontrolléiere wëllt, ob de Connector nach ëmmer prett ass.
MCP-Astellunge vun TypingMind mat aktivem Server an dem Knäppchen „Serveren änneren“
{
  "mcpServers": {
    "codemesh": {
      "command": "npx",
      "args": [
        "-y",
        "codemesh"
      ]
    }
  }
}
4

D'Verbindung mat verschiddene Modeller benotzen

Späichert d'Serverlëscht, maacht „Plugins“ op an aktivéiert d'MCP-Tools vu CodeMesh MCP Server. Wielt dann e belibegen ënnerstëtzte KI-Modell an TypingMind a benotzt d'Tools am Chat oder weist se engem KI-Agent zou.

  1. Maacht d'Säit „Plugins“ an TypingMind op.
  2. Aktivéiert d'MCP-Tools vu CodeMesh MCP Server.
  3. Start e Chat a wielt de KI-Modell, deen Dir benotze wëllt.
  4. Benotzt d'MCP-Tools am Chat oder weist se engem KI-Agent zou.
  5. Wiesselt bei Bedarf op en anere KI-Modell, ouni MCP nei ze verbannen.
TypingMind-Chat mat aktivéierte MCP-Tools an engem ausgewielte KI-Modell
Hëlleft Dir mir bei dëser Aufgab mat CodeMesh MCP Server?
CodeMesh MCP Server
Jo. Ech hunn et gelies.
Dat hunn ech mat CodeMesh MCP Server fonnt.

Heefeg gestallte Froen

Fir wat gëtt de MCP-Server CodeMesh MCP Server benotzt?

CodeMesh MCP Server ass e MCP-Server, deen et kompatibele KI-Clienten erlaabt, sech mat externen Tools a Kontext ze verbannen. An TypingMind kënnt Dir dëse MCP-Server eemol derbäisetzen a seng Tools an Ärem KI-Aarbechtsberäich zur Verfügung stellen.

Kann ech CodeMesh MCP Server MCP mat méi KI-Modeller an TypingMind benotzen?

Jo. TypingMind verbënnt MCP-Tools um Niveau vum Aarbechtsberäich. Sou kënnt Dir CodeMesh MCP Server mat verschiddene KI-Modeller wéi Claude, ChatGPT, Gemini oder anere Modeller benotzen, déi Dir an TypingMind konfiguréiert hutt, ouni de MCP-Server fir all Modell separat anzeriichten.

Firwat CodeMesh MCP Server MCP mat TypingMind benotzen?

TypingMind ass eng vun de beschte Benotzeruewerfläche fir LLM-Chat, well et méi KI-Modeller, Prompts, Plugins, KI-Agenten, API-Schlësselen a MCP-Tools an engem Aarbechtsberäich zesummebréngt. Wann CodeMesh MCP Server verbonnen ass, kënnt Dir seng MCP-Tools mat Äre bevorzugte Modeller benotzen a gläichzäiteg Är Chataarbecht an TypingMind organiséieren.

Wéi verbannen ech CodeMesh MCP Server MCP mat TypingMind?

CodeMesh MCP Server leeft iwwer de lokale MCP-Connector vun TypingMind. Dat eegent sech am beschten, wann de MCP-Server Zougrëff op lokal Fichieren, Desktop-Apps, Kommandozeilen-Tools oder privat Ressourcen op Ärem Computer brauch.

Wéi eng Tools stellt CodeMesh MCP Server MCP an TypingMind zur Verfügung?

CodeMesh MCP Server stellt 5 MCP-Tools zur Verfügung, déi Dir op der Plugins-Säit vun TypingMind aktivéiere kënnt, fir se am Chat ze benotzen oder KI-Agenten zouzeweisen.

Muss ech meng API-Schlëssele mat TypingMind deelen, fir CodeMesh MCP Server MCP ze benotzen?

Nee. TypingMind setzt op lokal Veraarbechtung a léisst Iech d'Kontroll iwwer Är Modellubidder, API-Schlësselen, Prompts a MCP-Konfiguratioun. Wann CodeMesh MCP Server eng Authentifizéierung verlaangt, setzt déi néideg Headeren, OAuth-Astellungen oder lokal Konfiguratioun fir dee MCP-Server derbäi, wann Dir d'Verbindung erstallt.

Änlech MCP-Serveren

All weisen

Elo Ären eegene KI-Workspace ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇