← Back to Dashboard
1. Project Scaffolding2. Registering Tools3. Adding Resources & Prompts4. Connecting & Publishing

Connecting & Publishing

📚 Build Your First Server10 min100 XP⌨ Hands-on lab

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.
⌨ HANDS-ON LABRegister Your Server with a Client
⭐ +150 XP

Your notes-server builds cleanly. Now plug it into a real host: register it with Claude Code, then confirm the client sees it.

1Register the server with Claude Code using `claude mcp add` (name it, then pass the launch command after --).
2Verify the registration by listing configured MCP servers.
lab-sandbox — simulated environment
INFINITY LAB SANDBOX v2.6 — simulated shell
Type the command for the current objective. Helpers: "hint", "solution", "clear".
$
OBJECTIVE 1 / 2 — type "hint" if stuck
🧪 Knowledge Check
Press 1-4 to select1 of 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
Connecting & Publishing Tutorial | Build Your First Server — MCP Academy