Website | Source | Specification | Docs

SDKs:

MCP Apps

Concepts

MCP servers can provide three main types of capabilities:

Connection lifecycle:

  1. Initialization
    1. Client sends initialize request with protocol version and capabilities
    2. Server responds with its protocol version and capabilities
    3. Client sends initialized notification as acknowledgment
    4. Normal message exchange begins
  2. Message exchange: After initialization, the following patterns are supported:
    • Request-Response: Client or server sends requests, the other responds
    • Notifications: Either party sends one-way messages
  3. Termination: Either party can terminate the connection:
    • Clean shutdown via close()
    • Transport disconnection
    • Error conditions

Reading

Example Agents

Example Servers

MCP Server implementation example

import asyncio
import mcp.types as types
from mcp.server import Server
from mcp.server.stdio import stdio_server

app = Server("example-server")

@app.list_resources()
async def list_resources() -> list[types.Resource]:
    return [
        types.Resource(
            uri="example://resource",
            name="Example Resource"
        )
    ]

async def main():
    async with stdio_server() as streams:
        await app.run(
            streams[0],
            streams[1],
            app.create_initialization_options()
        )

if __name__ == "__main__":
    asyncio.run(main())

Another MCP server example

Setup

npm init -y
npm install @modelcontextprotocol/sdk

Code

import { createServer } from '@modelcontextprotocol/sdk/server/index.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';

// Create the MCP server
const server = createServer({
  name: 'ollama-mcp-server',
  version: '1.0.0',
});

// 1. Define the tool (What it does)
server.setRequestHandler(ListToolsRequestSchema, async () => {
  return {
    tools: [
      {
        name: "add_numbers",
        description: "Adds two numbers together and returns the result",
        inputSchema: {
          type: "object",
          properties: {
            a: { type: "number", description: "The first number" },
            b: { type: "number", description: "The second number" }
          },
          required: ["a", "b"]
        }
      }
    ]
  };
});

// 2. Handle the tool call (How it works)
server.setRequestHandler(CallToolRequestSchema, async (request) => {
  const { name, arguments: args } = request.params;

  if (name === "add_numbers") {
    const result = args.a + args.b;
    return {
      content: [
        {
          type: "text",
          text: `The sum of ${args.a} and ${args.b} is ${result}.`
        }
      ]
    };
  }

  throw new Error(`Unknown tool: ${name}`);
});

// 3. Start the server
async function main() {
  const transport = new StdioServerTransport();
  await server.connect(transport);
}

main().catch((err) => {
  console.error("Server error:", err);
  process.exit(1);
});

Configuring it for use with Ollama: Find your config file. Mac/Linux: ~/.ollama/config.json; Windows: %APPDATA%\Ollama\config.json. Add the tool to the config: Open the config file (create it if it doesn't exist) and add a tools section. The value of handler must be the absolute path to your server.js file.

```json
{
  "tools": [
    {
      "name": "add_numbers",
      "description": "Adds two numbers together",
      "handler": "/full/path/to/your/project/server.js"
    }
  ]
}
```

Once you have saved the configuration file, you must restart Ollama for the changes to take effect.

Start a conversation with a model (e.g., ollama run llama3) and ask it to use your tool.

>>> Can you add 50 and 25 for me?

If successful, the model should invoke your MCP tool, and you should see output indicating the tool ran and the result (75).

Reference implementations

These official reference servers demonstrate core MCP features and SDK usage:

Current reference servers

Archived servers (historical reference)

⚠️ Note: The following servers have been moved to the servers-archived repository and are no longer actively maintained. They are provided for historical reference only.

Data and file systems
Development tools
Web and browser automation
Productivity and communication
AI and specialized tools

Getting started

Using reference servers

TypeScript-based servers can be used directly with npx:

npx -y @modelcontextprotocol/server-memory

Python-based servers can be used with uvx (recommended) or pip:

# Using uvx
uvx mcp-server-git

# Using pip
pip install mcp-server-git
python -m mcp_server_git

Configuring with Claude

To use an MCP server with Claude, add it to your configuration:

{
  "mcpServers": {
    "memory": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-memory"]
    },
    "filesystem": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-filesystem",
        "/path/to/allowed/files"
      ]
    },
    "github": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "<YOUR_TOKEN>"
      }
    }
  }
}


Tags: ai   distribution   standard  

Last modified 22 March 2026