Your server has tools, resources, and prompts. Now let's connect the transport and make it available to the world.
#!/usr/bin/env node
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: "notes-server",
version: "1.0.0"
});
// ... register all tools, resources, prompts ...
async function main() {
const transport = new StdioServerTransport();
await server.connect(transport);
console.error("Notes MCP Server running on stdio");
}
main().catch((error) => {
console.error("Fatal error:", error);
process.exit(1);
});
// ~/Library/Application Support/Claude/claude_desktop_config.json (Mac)
// %APPDATA%\Claude\claude_desktop_config.json (Windows)
{
"mcpServers": {
"notes": {
"command": "node",
"args": ["/absolute/path/to/dist/index.js"],
"env": {
"NOTES_DIR": "/Users/me/Documents/notes"
}
}
}
}
# Build and publish
npm run build
npm publish
# Users install globally:
npm install -g @yourscope/notes-server
# Then configure in their client:
{
"mcpServers": {
"notes": {
"command": "npx",
"args": ["-y", "@yourscope/notes-server"],
"env": { "NOTES_DIR": "~/notes" }
}
}
}
#!/usr/bin/env node shebang to your entry point"bin" field in package.jsonnpx -y pattern is the gold standard for MCP server distribution. Users don't need to install anything globally — npx downloads and runs the latest version automatically.