Development Pattern#

  • Use uv to initialize a new project
  • Create venv with uv venv
  • Add mcp and other dependencies
  • In Pyproject, add build system and script entry point
  • __init__.py should have a main() function that runs the server

Tools#

  • Implement a list_tools() handler that lists available tools
  • Implement any helper functions that do business logic
  • Implement call_tool() handler. Takes name str and arguments dict, name will correspond to name of tool in list_tools() handler
  • Implement a main function to run the server using packages from mcp.server

Prompts#

Prompt architecture

{
  name: string;              // Unique identifier for the prompt
  description?: string;      // Human-readable description
  arguments?: [              // Optional list of arguments
    {
      name: string;          // Argument identifier
      description?: string;  // Argument description
      required?: boolean;    // Whether argument is required
    }
  ]
}
  • prompts/list endpoint allows for prompt discovery.
  • Use a prompt with prompts/get
  • Best Practices

Source#

https://modelcontextprotocol.io/quickstart#claude-for-desktop-integration-issues