Skip to main content
Glama
binodrajpandey

MCP Server Example

MCP Server Example

A simple MCP (Model Context Protocol) server for learning the core primitives: Tools, Resources, and Prompts.

Setup

Prerequisites

  • Python 3.10+

  • uv

Install

uv sync

Related MCP server: MCP AI Chat LangChain

Test

uv run mcp dev server.py

Opens a browser UI at http://localhost:6274. From there you can:

  • Tools tab: call save_note, delete_note with custom inputs

  • Resources tab: read notes://list or notes://{name}

  • Prompts tab: run summarize_notes or brainstorm with arguments

Option 2 — CLI with mcp client

List all available tools:

echo '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}' | uv run python server.py

Connect to Claude Code (CLI)

Add the server to your Claude Code session:

claude mcp add learning-mcp -- uv run --directory /Users/binod/projects/mcp-example python server.py

Verify it's connected:

claude mcp list

Once added, Claude Code can call your tools directly in the chat — just ask it to, e.g. "save a note called 'ideas'".

Connect to Claude Desktop

Add this to ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "learning-mcp": {
      "command": "uv",
      "args": [
        "run",
        "--directory", "/Users/binod/projects/mcp-example",
        "python", "server.py"
      ]
    }
  }
}

Then restart Claude Desktop.

Use programmatically (Python)

Use the mcp library to call tools, read resources, and fetch prompts from your own code:

from mcp import ClientSession
from mcp.client.stdio import stdio_client, StdioServerParameters
import asyncio

async def main():
    server = StdioServerParameters(
        command="uv", args=["run", "python", "server.py"]
    )
    async with stdio_client(server) as (read, write):
        async with ClientSession(read, write) as session:
            await session.initialize()

            # Read a resource
            notes = await session.read_resource("notes://list")
            print(notes)

            # Get a prompt
            prompt = await session.get_prompt("brainstorm", {"topic": "side projects"})
            print(prompt)

asyncio.run(main())

To let Claude (via Anthropic API) call your tools, add anthropic[mcp] to your dependencies and convert the tools:

from anthropic.lib.tools.mcp import async_mcp_tool
import anthropic

client = anthropic.AsyncAnthropic()
tools = [async_mcp_tool(t, session) for t in (await session.list_tools()).tools]

runner = client.beta.messages.tool_runner(
    model="claude-opus-4-6",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Save a note called ideas"}],
    tools=tools,
)
async for message in runner:
    for block in message.content:
        if hasattr(block, "text"):
            print(block.text)

What's inside

File

Description

server.py

MCP server with tools, resources, and prompts

pyproject.toml

Project dependencies

Tools (Claude can call these)

Tool

Description

save_note(name, content)

Save a note

delete_note(name)

Delete a note

Resources (Claude can read these)

URI

Description

notes://list

List all saved notes

notes://{name}

Read a specific note

Prompts (reusable templates)

Prompt

Description

summarize_notes

Summarize all saved notes

brainstorm(topic)

Brainstorm ideas on a topic

Available Tools

4 tools
addA

Add two numbers.

ParametersJSON Schema
NameRequiredDescriptionDefault
aYes
bYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.1/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden. 'Add two numbers' fully describes the behavior for a pure arithmetic operation with no side effects, hidden state, or special requirements. The simplicity of the operation makes this sufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, ultra-concise sentence with no wasted words. It is perfectly front-loaded and every word earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a trivial two-number addition with an output schema and no nested objects, the description is complete. The simplicity of the tool means no further context is required.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It mentions 'two numbers' which maps to parameters a and b, but does not provide individual parameter detail. Since addition is commutative, order is irrelevant, and the description is minimally adequate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Add two numbers' clearly states the specific verb 'Add' and the resource 'two numbers', which unambiguously distinguishes this from sibling tools like subtract, multiply, and divide.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description does not explicitly state when to use this tool versus alternatives, but the purpose itself implies usage: use when you need to add two numbers. No exclusions or alternative recommendations are provided, so it relies on the obviousness of the operation.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

delete_noteC

Delete a note by name.

ParametersJSON Schema
NameRequiredDescriptionDefault
nameYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

C2.7/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool deletes a note, implying a destructive mutation, but doesn't cover critical aspects like permissions needed, whether deletion is reversible, error handling, or confirmation requirements. This leaves significant gaps in understanding the tool's behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with no wasted words. It's front-loaded with the core action and resource, making it easy to parse quickly, which is ideal for conciseness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a destructive tool with no annotations, 0% schema coverage, and an output schema (which helps but isn't described), the description is incomplete. It lacks details on behavior, parameters, and usage context, making it inadequate for safe and effective tool invocation by an agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, and the description only mentions 'by name' without explaining what 'name' refers to (e.g., note title, ID, filename), its format, or constraints. With one undocumented parameter, the description fails to compensate for the lack of schema details, providing minimal semantic value.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Delete') and resource ('a note'), making the purpose unambiguous. It doesn't distinguish from siblings like 'save_note', but it's specific enough to understand the basic function without being tautological.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives like 'save_note' or other sibling tools. The description only states what it does, not when it should be selected, leaving the agent without context for decision-making.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

multiplyA

Multiply two numbers.

ParametersJSON Schema
NameRequiredDescriptionDefault
aYes
bYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A3.6/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations are absent, so the description carries the full burden for behavioral disclosure. 'Multiply two numbers' accurately describes the core operation, but does not disclose edge cases, error handling, or return behavior. However, for a trivial arithmetic operation, this minimal description is acceptable and not misleading.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence, 'Multiply two numbers,' with no filler words or redundant information. It is effectively front-loaded and maximally concise.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple two-number multiply tool with an existing output schema, the description covers the essential purpose. It lacks details on return values or edge cases, but these are not critical given the tool's triviality and the presence of an output schema.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate for the lack of parameter details. It confirms that both parameters are numbers and are to be multiplied, but does not explain individual roles. Since multiplication is commutative, the symmetry reduces the need for further clarification.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states the specific verb 'Multiply' and the resource 'two numbers', which clearly distinguishes it from sibling tools like add, subtract, divide, power, square_root, and percentage. There is no ambiguity about what the tool does.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is given on when to use this tool versus the sibling arithmetic operations. The description does not mention any alternatives, exclusions, or context for when multiplication is preferred.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

save_noteC

Save a note with a given name.

ParametersJSON Schema
NameRequiredDescriptionDefault
nameYes
contentYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

C2.4/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It implies a write operation ('save') but doesn't specify permissions, whether it overwrites existing notes, or what happens on success/failure. This is inadequate for a mutation tool with zero annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with no wasted words. It's appropriately sized for a simple tool, though it could be more informative without sacrificing brevity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 2-parameter mutation tool with no annotations and 0% schema coverage, the description is incomplete. It lacks details on behavior, parameters, and usage context. While an output schema exists, the description doesn't address key aspects like what 'save' entails or how it differs from siblings.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the schema provides no parameter details. The description mentions 'name' but doesn't explain its role or format, and omits 'content' entirely. It adds minimal value beyond the schema, failing to compensate for the coverage gap.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Save a note with a given name' clearly states the action (save) and resource (note), but it's vague about scope and doesn't distinguish from siblings like 'add' or 'delete_note'. It doesn't specify whether this creates new notes or updates existing ones, which limits clarity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives like 'add' or 'delete_note'. The description lacks context about prerequisites, such as whether a note must exist or if this creates new notes, leaving usage unclear.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 4 tool updatesv0.1.0
    • First observedadd
    • First observeddelete_note
    • First observedmultiply
    • First observedsave_note

TDQS

C2.6/5.0

Scored across 4 tools

Disambiguation2/5

The tools fall into two unrelated domains (arithmetic and note management) with no overlap within each domain, but the set as a whole is confusing because add/multiply and delete_note/save_note serve completely different purposes. An agent might struggle to understand why these tools are grouped together, though individual tools are distinct.

Naming Consistency2/5

Naming is inconsistent across the set: add and multiply use simple verbs without objects, while delete_note and save_note follow a verb_noun pattern. This mixed convention lacks a predictable pattern, making the tool set harder to navigate.

Tool Count3/5

With 4 tools, the count is reasonable for a small server, but it feels thin and poorly scoped because it covers two unrelated domains. For either arithmetic or note management alone, 4 tools would be appropriate, but combined, it suggests an incomplete or mismatched purpose.

Completeness2/5

For arithmetic, basic operations like subtraction and division are missing, leaving gaps. For note management, there's no way to list or retrieve notes, creating dead ends. The server lacks a clear domain, making completeness hard to assess, but obvious gaps exist in both inferred areas.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    D
    maintenance
    A demonstration implementation of a Model Context Protocol server that provides simple mathematical tools (add, subtract) and personalized greeting resources.
    -
  • A
    license
    Not graded
    quality
    Not graded
    maintenance
    A demonstration MCP server that provides calculator tools for arithmetic operations, personalized greeting resources, and code review prompt templates. Enables users to perform basic math calculations, generate dynamic greetings, and access reusable code review templates through the Model Context Protocol.
    MIT