Platform
MCP Server guide
StateAnchor can generate a fully compliant Model Context Protocol (MCP) server — letting AI agents like Claude, Cursor, and ChatGPT interact with any API directly, without writing glue code.
Costs 2 credits per generation. MCP servers are more complex than standard wrappers and use 2 credits instead of 1.
What is MCP?
Model Context Protocol is an open standard that lets AI assistants call external tools and APIs. Instead of copy-pasting your API wrapper into a prompt, you expose it as an MCP server — and the AI model can discover and call your API's methods directly.
StateAnchor generates a complete MCP server in TypeScript (Node.js) that:
- Exposes each API endpoint as a named MCP tool
- Includes full JSON Schema definitions for all parameters
- Handles authentication via environment variables
- Returns structured responses the AI model can reason about
- Includes a README with installation and configuration instructions
Generating an MCP server
On the Generate page, toggle MCP Server mode before generating. The description format is the same as a standard wrapper — describe your API's endpoints and StateAnchor handles the MCP-specific scaffolding.
TIP: MCP servers work best when you describe your API's purpose clearly. Claude will use the tool descriptions to decide when and how to call your API.
Example output
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import {
CallToolRequestSchema,
ListToolsRequestSchema,
} from "@modelcontextprotocol/sdk/types.js";
import fetch from "node-fetch";
const API_KEY = process.env.OPENWEATHER_API_KEY;
const BASE = "https://api.openweathermap.org/data/2.5";
const server = new Server(
{ name: "openweather-mcp", version: "1.0.0" },
{ capabilities: { tools: {} } }
);
server.setRequestHandler(ListToolsRequestSchema, async () => ({
tools: [
{
name: "get_current_weather",
description: "Get current weather conditions for a city",
inputSchema: {
type: "object",
properties: {
city: { type: "string", description: "City name" },
},
required: ["city"],
},
},
],
}));
const transport = new StdioServerTransport();
await server.connect(transport);Connecting to Claude (claude.ai)
Add your MCP server to Claude Desktop's config file:
// macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
// Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"openweather": {
"command": "node",
"args": ["/path/to/your/openweather-mcp/index.js"],
"env": {
"OPENWEATHER_API_KEY": "your_api_key_here"
}
}
}
}After saving and restarting Claude Desktop, the weather tools will appear in the tools panel. Claude can now call get_current_weather and get_forecast when answering questions about weather.
Connecting to Cursor
In Cursor, open Settings → MCP and add your server:
{
"mcpServers": {
"openweather": {
"command": "node",
"args": ["/path/to/openweather-mcp/index.js"],
"env": { "OPENWEATHER_API_KEY": "your_key" }
}
}
}NOTE: The generated README includes platform-specific installation instructions for Claude Desktop, Cursor, and the MCP CLI. You don't need to memorize these steps.
Environment variables
StateAnchor never hardcodes API keys. All credentials are read from environment variables at startup. The generated README lists every required variable and how to set them.
WARNING: Never commit your.envfile. Add it to.gitignorebefore pushing your MCP server to a repository.