Skip to main content
Glama

Example MCP Server

An MCP (Model Context Protocol) server that provides access to the Example API, allowing AI assistants to interact with Example data.

Features

  • List and retrieve items from the Example API

  • Async HTTP client with error handling

  • Typed responses with Pydantic models

  • Built on the NimbleBrain server SDK: annotated tools, classified errors, a skill served to the host, and a Server Card

Related MCP server: agenticjobs

Installation

# Configure your API key
mpak config set @nimblebraininc/example api_key=your_api_key_here

# Run the server
mpak run @nimblebraininc/example

Manual Installation

# Clone the repository
git clone https://github.com/NimbleBrainInc/mcp-example.git
cd mcp-example

# Install dependencies with uv
uv sync

# Set your API key
export EXAMPLE_API_KEY=your_api_key_here

# Run the server
uv run python -m mcp_example.server

Configuration

Getting Your API Key

  1. Go to https://example.com/settings/api

  2. Create a new API key

  3. Copy the key

Claude Desktop Configuration

Add to your ~/.claude/settings.json:

{
  "mcpServers": {
    "example": {
      "command": "mpak",
      "args": ["run", "@nimblebraininc/example"]
    }
  }
}

Available Tools

Tool

Description

list_items

List items from the API with optional limit. Each row carries a uri and a preview of the description

get_item

Get a single item, whole, by its ID

Both tools read and change nothing, and say so with the READS annotation. A row's uri (example://items/<id>) is a resource that returns the whole item as JSON. The server also serves one skill, skill://example/SKILL.md, which tells an agent when to use each tool.

Built on the NimbleBrain server SDK

The server uses nimblebrain-server-sdk for what every server on NimbleBrain shares. Start with the quickstart.

The server does this

With

Guide

Declares what each tool can change

READS, ADDS, CHANGES

Quickstart

Returns a failure with a code the caller can act on

add_error_contract, ServiceError, ErrorCode

Errors

Serves the skill in src/mcp_example/skills/

add_skills

Skills

Names and describes itself to a host before it connects

add_server_card

Server Card

Tests what a host sees, on both protocol versions

Mode, served_skills, assert_bounded_rows

Testing

A tool

A tool carries one annotation: READS, ADDS (a write that loses nothing) or CHANGES (a write that overwrites or removes). It reports a failure by raising ServiceError, and add_error_contract, called once where the server is built, returns it to the caller as an error result. A tool never returns a dict that describes an error: a host and a model score that as a success.

from fastmcp import FastMCP
from nimblebrain_server_sdk import ADDS, add_error_contract
from nimblebrain_server_sdk.errors import ErrorCode, ServiceError

mcp = FastMCP("com.example/example", version="0.1.0")
add_error_contract(mcp)

ITEMS: dict[str, str] = {}


@mcp.tool(annotations=ADDS)
async def create_item(name: str) -> dict[str, str]:
    """Create an item and return it."""
    if not name.strip():
        raise ServiceError(ErrorCode.BAD_INPUT, "`name` is empty.")
    item_id = str(len(ITEMS) + 1)
    ITEMS[item_id] = name
    return {"id": item_id, "name": name}

The caller of create_item with an empty name receives an error result whose structured content is {"error": {"code": "bad_input", "retryable": false, "message": "name is empty."}}.

A skill

A skill is a directory that holds a SKILL.md. The frontmatter needs a name and a description, and name must equal the directory's name. add_skills checks every skill when the server is imported and serves each at skill://<name>/SKILL.md:

from pathlib import Path

from fastmcp import FastMCP
from nimblebrain_server_sdk import add_skills

mcp = FastMCP("com.example/example", version="0.1.0")
add_skills(mcp, [Path("src/mcp_example/skills/example")])

A test

A host connects on one of two protocol versions, so a test runs on both: Client(mcp, mode="auto") negotiates 2026-07-28 and mode="legacy" runs the 2025-11-25 handshake. Mode is the type of that parameter. served_skills reads every skill file back the way a host does.

import pytest
from fastmcp import Client
from nimblebrain_server_sdk.testing import Mode, served_skills

from mcp_example.server import mcp


@pytest.mark.parametrize("mode", ["auto", "legacy"])
async def test_the_skill_is_served(mode: Mode) -> None:
    skills = await served_skills(mcp, mode)
    assert set(skills) == {"skill://example/SKILL.md"}


@pytest.mark.parametrize("mode", ["auto", "legacy"])
async def test_an_empty_item_id_is_bad_input(mode: Mode) -> None:
    async with Client(mcp, mode=mode) as client:
        result = await client.call_tool("get_item", {"item_id": " "}, raise_on_error=False)
    assert result.is_error
    assert result.structured_content["error"]["code"] == "bad_input"

tests/test_server.py holds the full set.

A Server Card

A host that has only the server's URL reads its Server Card, at <mcp-url>/server-card, to name and describe it before it connects. name and version come from the FastMCP constructor, so the server is named in reverse-DNS form and given its own version (without version=, FastMCP reports its own). title and description are 1 to 100 characters:

from fastmcp import FastMCP
from nimblebrain_server_sdk import add_server_card

from mcp_example import __version__

mcp = FastMCP("com.example/example", version=__version__)
add_server_card(mcp, title="Example", description="List and read items from the Example API.")

The card is served over streamable HTTP only: make run-http, then curl -s http://127.0.0.1:8000/mcp/server-card. This server is a connector, so the card has no placements; an app's server passes them for its ui:// views.

Deploying: server.json

server.json is an MCP Registry ServerDetail: what an operator adds to a deployed NimbleBrain's connectors catalog, and what mcp-publisher lists on the official MCP Registry. It restates the card's name, title, description and version, and adds remotes, the URL the server is deployed at. Replace the placeholder https://mcp.example.com/mcp with yours. tests/test_server_card.py fails when server.json and the served card disagree, and make bump moves both versions together.

Development

# Install dev dependencies
uv sync --dev

# Run tests
uv run pytest tests/ -v

# Format code
uv run ruff format src/ tests/

# Lint
uv run ruff check src/ tests/

# Type check
uv run ty check src/

# Run all checks
make check

# Serve over HTTP at http://127.0.0.1:8000/mcp
make run-http

make run-http binds loopback. On Linux, a NimbleBrain running in Docker reaches the host through the Docker bridge: make run-http HOST=172.17.0.1, or HOST=0.0.0.0, which also exposes the server to the network.

License

MIT

Tool Schema Changelog

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

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      C
      maintenance
      Enables agents to search and deduplicate UK job vacancies across multiple boards, match them against local CVs, and submit complete applications through an automated browser with persistent logins and application memory.
      29
      MIT
    • A
      license
      Not graded
      quality
      A
      maintenance
      Enables agents to find and apply to jobs, and employers to post jobs, through a self-hosted job board with human oversight.
      36 npm
      4
      MIT
    • A
      license
      C
      quality
      C
      maintenance
      Enables AI agents to fill real job application forms in a real browser, remember previous answers across applications, and enforce guardrails such as confirmation before submission and asking rather than guessing unknown fields.
      32
      MIT