Skip to main content

Overview

Built-in MCP servers live in the packages/ directory and run as stdio processes alongside the platform. Each server exposes tools that agents can call during a run.
Just want to connect an existing MCP server without modifying the platform? See Add a Custom MCP Server to add one through the portal UI.
muxAI ships with several built-in servers you can reference as examples:

Quick start

1. Create the package

Create packages/mcp-my-server/index.js:
All MCP server dependencies live in the root package.json, not in individual packages. This keeps installs fast and avoids duplication.

2. Register in the MCP registry

Add an entry to config/mcp-registry.json:
The tools array is metadata for the UI. The actual tool definitions come from your server’s ListToolsRequestSchema handler.

3. Test it

Restart the platform (pnpm dev) and check the MCP Servers page. Your server should appear in the Built-in section. Create an agent in Built-in MCP mode and it will have access to your tool.

Common patterns

Direct tool

The simplest pattern. Your server does the work directly — call an API, process data, return results. See mcp-chart-analyst for a clean example: it fetches an image URL, converts to base64, and returns it for Claude to analyze.

Proxy to a remote MCP

When an MCP server already exists as a remote HTTP endpoint, you can wrap it as a local stdio server. This keeps the registry format consistent and lets the platform manage it like any other built-in. See mcp-docs for this pattern: it proxies to a Mintlify MCP endpoint.

Internal API access

Servers that need to call the muxAI API (like the orchestrator or contractor servers) can use environment variables injected at runtime:
  • MUXAI_API_URL — the API base URL (e.g. http://localhost:3001)
  • MUXAI_INTERNAL_SECRET — secret for authenticated internal requests
  • MUXAI_AGENT_ID, MUXAI_AGENT_NAME, MUXAI_AGENT_ROLE — the calling agent’s identity

Return types

MCP tools can return different content types:

Settings toggle (optional)

If you want users to be able to enable or disable your server from the Settings page, add an entry to the BUILTIN_SERVERS array in apps/web/src/app/settings/page.tsx:
The platform already reads the mcp_disabled_servers setting at runtime and filters out any disabled server IDs when building the MCP config. No backend changes needed — just the UI entry.
Servers listed in CORE_SERVERS (like wallet and orchestrator) cannot be toggled off. Only add your server there if it is essential for platform operation.

Tips

  • Logging: Use process.stderr.write() for debug output. MCP uses stdout for protocol messages, so console.log will break things.
  • Timeouts: Always set AbortSignal.timeout() on fetch calls to avoid hanging the agent’s run.
  • Tool descriptions: Write descriptions as if briefing an agent. Be specific about what the tool does and when to use it. The agent decides which tools to call based on these descriptions.
  • Naming: Use snake_case for tool names. The full tool name the agent sees is mcp__<server-id>__<tool-name>.
  • No package.json needed: Dependencies go in the root package.json. Just import what you need.