Creating an MCP Server
Build a Model Context Protocol server and publish it to the marketplace.
What is MCP?
The Model Context Protocol (MCP) is an open standard that lets AI assistants connect to external tools and data sources. An MCP server exposes capabilities — like reading files, querying databases, or calling APIs — that AI models can use during a conversation.
By publishing an MCP server on p001.ai, you make it discoverable to thousands of developers who want to extend their AI workflows.
Prerequisites
- Node.js 18+ installed
- npm or another package manager
- The
@modelcontextprotocol/sdkpackage - A p001.ai account
1. Create a new MCP server project
Start by scaffolding a new Node.js project and installing the MCP SDK:
mkdir my-mcp-server && cd my-mcp-server
npm init -y
npm install @modelcontextprotocol/sdk2. Implement your server
Create an index.ts file that defines your server and its tools:
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { z } from "zod";
const server = new McpServer({
name: "my-mcp-server",
version: "1.0.0",
});
// Define a tool
server.tool(
"hello",
"Say hello to someone",
{ name: z.string().describe("Name to greet") },
async ({ name }) => ({
content: [{ type: "text", text: `Hello, ${name}!` }],
})
);
// Start the server
const transport = new StdioServerTransport();
await server.connect(transport);This example creates a simple tool that takes a name and returns a greeting. In practice, your tools can do anything — call APIs, read files, run queries, or integrate with third-party services.
3. Test locally
Test your MCP server with an AI client. Add this to your Claude Desktop config (or any MCP-compatible client):
{
"mcpServers": {
"my-mcp-server": {
"command": "npx",
"args": ["tsx", "/path/to/my-mcp-server/index.ts"]
}
}
}Restart the client and verify your tools appear and work correctly.
4. Publish to npm
Package your server and publish it to npm so users can install it with npx:
# Add a bin entry to package.json
# "bin": { "my-mcp-server": "./dist/index.js" }
npm run build
npm publish5. Publish to the p001.ai marketplace
Go to your dashboard and fill in the publish form:
- Name — your server name as it will appear in the marketplace.
- Description — a short summary (max 200 characters) shown on cards.
- Detailed description — full documentation in markdown. Include features, usage, and examples.
- Category & tags — help users discover your MCP.
- Config snippet — the JSON config users paste into their client to install your MCP.
- Version & changelog — semver string and release notes for the initial version.
6. Config snippet format
The config snippet is what users paste into their AI client to install your server. A typical snippet looks like this:
{
"mcpServers": {
"my-mcp-server": {
"command": "npx",
"args": ["-y", "my-mcp-server"]
}
}
}If your server requires environment variables (e.g. an API key), add an env section:
{
"mcpServers": {
"my-mcp-server": {
"command": "npx",
"args": ["-y", "my-mcp-server"],
"env": {
"API_KEY": "your-api-key-here"
}
}
}
}7. Versioning
After publishing, you can release new versions from your dashboard. Each version has a semver string (e.g. 1.1.0) and a changelog. The latest version is displayed on the detail page.
Users see the full version history and can reference specific versions if needed.
Next steps
Want to charge for your MCP? Read the Monetization guide to learn about pricing, subscriptions, and license keys.