[ ABORT TO HUD ]
SEQ. 1
SEQ. 2
SEQ. 3
SEQ. 4

Connecting & Publishing

🛠️ Build Your First Server10 min100 BASE XP

Wiring It All Up

Your server has tools, resources, and prompts. Now let's connect the transport and make it available to the world.

Complete Entry Point

#!/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);
});

Claude Desktop Configuration

// ~/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"
      }
    }
  }
}

Publishing to npm

# 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" }
    }
  }
}

Publishing Checklist

  • ☐ Add the #!/usr/bin/env node shebang to your entry point
  • ☐ Set the "bin" field in package.json
  • ☐ Document all required environment variables in README
  • ☐ Test with the MCP Inspector before publishing
  • ☐ Add to the community registry at mcp.so
💡 Key Insight: The npx -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.
SYNAPSE VERIFICATION
QUERY 1 // 3
Why must you use console.error() instead of console.log() in stdio servers?
console.log is slower
console.log writes to stdout which corrupts the JSON-RPC protocol stream
console.error has colors
It doesn't matter
Watch: 139x Rust Speedup
Connecting & Publishing | Build Your First Server — MCP Academy