HEP-KE

Science MCP Server Starter

Community HEP-KE
Updated

MCP server starter code to expose science tools for agent use

Science MCP Server Starter

CItutorial · part of the HEP-KE MCP server library

Minimal starter code for wrapping science functions as MCP tools. It is thesmallest complete instance of the HEP-KE MCP server standard: copy it to starta new server. The science code stays normal Python; the generic MCP wrapper(mcp_server/) only imports the public tool functions listed inpyproject.toml and exposes them through FastMCP, together with theserver-side skills in skills/.

This repo only defines the MCP server. Agent code lives in the client repo thatconnects to it.

At a glance

Category tutorial
Domain none (demo functions)
HPC dispatch no (see Add HPC dispatch later)
Skill prefix demo (list_demo_skills, load_demo_skill)
Default port 8000 (streamable-http)
Hosted endpoint none

Connect Science Code

The whole loop for a new server is: write a function in tools/, list themodule in pyproject.toml, add a skill .md, run the tests.

pyproject.toml            [tool.mcp-server]: name, skill prefix, port, tool modules
mcp_server/               generic wrapper (copied from the standard, never edited)
mcp_server/INSTRUCTIONS.md   what your server does - the one per-server file in mcp_server/
tools/common.py           ArtifactResult, ok(), output helpers
tools/meta/               generic: list_<prefix>_skills / load_<prefix>_skill
tools/demo/               your science code: one sub-package per tool family
skills/*.md               recipes that chain your tools (also served as MCP prompts)
tests/                    test_contract.py + smoke_server.py (generic), test_demo.py (yours)
  1. Create normal Python functions in a tool family under tools/(this repo uses tools/demo/). Validate arguments with Pydantic, say inthe docstring when to use the tool, write files to output_dir, and returnok(...):
from typing import Annotated
from pydantic import Field, validate_call
from ..common import ArtifactResult, ok, resolve_outdir

@validate_call
def plot_sine_wave(
    output_dir: Annotated[str, Field(min_length=1, description="Directory for output files.")],
    num_points: Annotated[int, Field(ge=2, le=1000, description="Number of samples.")] = 200,
) -> ArtifactResult:
    """Plot one period of sin(x) and save it as a PNG in output_dir.

    Use this tool when a workflow needs a simple generated plot artifact.
    """
    outdir = resolve_outdir(output_dir)
    ...
    return ok("Generated sine wave plot.", [plot_path], num_points=num_points)
  1. Export only the MCP tools from the family's __init__.py.
from .science_tools import generate_random_points, plot_points, plot_sine_wave

__all__ = ["generate_random_points", "plot_sine_wave", "plot_points"]

Only names in __all__ become MCP tools. Helper functions stay private. Thisstarter does not scan a repo for functions.

  1. List the module in pyproject.toml (tools.meta stays first).
dependencies = [
    "mcp[cli]>=1.27,<2",
    "pydantic>=2,<3",
]

[tool.mcp-server]
name = "Science MCP Server"
skill_prefix = "demo"
port = 8000
hpc = false
tags = ["tutorial"]
instructions_file = "mcp_server/INSTRUCTIONS.md"
tool_modules = ["tools.meta", "tools.demo"]
  1. Add a skill: a markdown file in skills/ whose frontmatter name equalsthe file stem. Every server ships <prefix>-tour.md plus at least onescience recipe.
---
name: random-points-scatter
description: Recipe - generate a reproducible random-point dataset and scatter-plot it
---
1. generate_random_points(output_dir, count, seed) ...
  1. Run the tests (tests/test_contract.py checks all of the above).
uv sync --extra dev
uv run pytest -m "not network and not slow"
uv run python tests/smoke_server.py

To start your own server from this one: copy the repo, rename tools/demo/,change [tool.mcp-server] (name, skill_prefix, a free port, tags) andmcp_server/INSTRUCTIONS.md, rename skills/demo-tour.md toskills/<prefix>-tour.md, and update .mcp.json. Keep the generic filesuntouched so _standard/sync.py can update them.

Tools

tool what it does
list_demo_skills / load_demo_skill server-side skills (also served as MCP prompts)
generate_random_points write a deterministic CSV of (x, y) points in the unit square
plot_points scatter-plot the x, y columns of a CSV (e.g. the one above) to a PNG
plot_sine_wave plot one period of sin(x) to a PNG

Demo Tools

The demo science package exposes:

generate_random_points(output_dir: str, count: int = 30, seed: int = 42) -> ArtifactResult
plot_sine_wave(output_dir: str, num_points: int = 200) -> ArtifactResult
plot_points(csv_path: str, output_dir: str) -> ArtifactResult

The type hints, docstrings, and Pydantic constraints become the MCP tool schemathat external agents see.

Successful artifact tools return:

{"status": "success", "files": ["..."], "message": "...", "metadata": {}}

Tools pass data to each other as file paths: plot_points takes the CSV thatgenerate_random_points wrote, not the numbers.

Skills

skill use it to
demo-tour a one-minute guided run through every tool
random-points-scatter make a reproducible random-point dataset, sanity-check it, and plot it

Install and run

git clone https://github.com/HEP-KE/science-starter-server.git && cd science-starter-server
uv sync                                  # creates this server's own .venv from uv.lock
./run_server.sh                          # stdio (what agent clients launch)
./run_server.sh --transport streamable-http --port 8000   # URL endpoint at http://127.0.0.1:8000/mcp

Without uv: python3.12 -m venv .venv && .venv/bin/pip install -e ..

Connect a client

Connect an agent with one transport.

Use stdio for a local MCP server that the agent's MCP client starts for you.Do not start the stdio server in a separate terminal. Configure the client withthe command and arguments to launch. Claude Code picks up .mcp.json from therepo directory automatically, or:

claude mcp add demo -- /path/to/science-starter-server/run_server.sh

A generic client config:

{
  "demo": {
    "transport": "stdio",
    "command": "/path/to/science-starter-server/run_server.sh",
    "args": ["--transport", "stdio"]
  }
}

Use streamable-http when the agent connects to an already running server.Start the server in a terminal:

./run_server.sh --transport streamable-http --host 127.0.0.1 --port 8000

Then point the agent at:

http://127.0.0.1:8000/mcp

Claude Desktop, Codex, ChatGPT, Antigravity and hep-genesis-agent: seethe library site.

demo-notebooks/demo_remote_database_search_mcp.ipynb is a self-containedwalk-through of MCP tool design (a read-only remote-database search server)driven from LangGraph and Archi.

Add HPC dispatch later

This starter has hpc = false. When a tool becomes heavy enough to run onALCF / NERSC, follow the "HPC dispatch" section of _standard/STANDARD.md inthe MCPs_servers library (reference implementation: supernova-data-server):

  1. Set hpc = true in [tool.mcp-server] and append "mcp_server.dispatch"last to tool_modules.
  2. Copy the generic mcp_server/dispatch.py (_standard/sync.py <dir> doesit once hpc = true). It adds set_dispatch, get_dispatch,auth_status and export_dispatch_pack.
  3. Move the compute into tools/<family>/kernels.py: pure functions, JSON-safearguments in, a JSON-safe dict out, files written to the working directory,importing only numpy/scipy/astropy and declared pip_deps.
  4. Declare them in the family's __init__.py as DISPATCH_KERNELS = {key: {"function": "<family>.kernels.<fn>", "args_shape", "pip_deps", "duration_hint_s", "returns"}}, and make the heavy tool branch onremote_site() (run_kernel(...) when a site is set, the same kernellocally otherwise). Mark it fn.weight = "heavy".
  5. Add skills/hpc-dispatch-handoff.md. The contract tests then check thedispatch tools, the pack and the kernels.

Development and tests

uv sync --extra dev
uv run ruff check .
uv run pytest -m "not network and not slow"   # contract + science tests (what CI runs)
uv run pytest -m network                       # tests that download public data (none here)
uv run python tests/smoke_server.py            # live stdio server: lists tools and prompts

The generic files (mcp_server/ except INSTRUCTIONS.md, tools/meta/,tests/test_contract.py, tests/smoke_server.py, .github/workflows/ci.yml,run_server.sh) come from the HEP-KE MCP server standard; do not edit themper server.

Limitations

The demo tools are deliberately trivial (random points, a sine wave); theyexist to show the structure, not to do science. No HPC dispatch, no dataregistry, no hosted endpoint.

Citation and license

MIT License, see LICENSE. Part of the HEP-KE MCP server library.

MCP Server · Populars

MCP Server · New

    atilaahmettaner

    TradingMCP: Market Data & Technical Analysis for AI Assistants

    MCP server for market analysis in AI assistants: screeners, multi-timeframe technical analysis, backtests and sentiment for crypto, stocks, forex and futures. 39 tools. Self-host free, or use the hosted version, TradingMCP.

    Community atilaahmettaner
    lifan-builds

    Faster Mac Use (fmu)

    Background-first, multi-cursor browser and native macOS computer-use engine for AI agents

    Community lifan-builds
    agent360dev

    Agent360 Browser MCP

    The browser tool that can stop and ask you. A 2FA code, a CAPTCHA, a choice only you can make: it asks on your screen, then carries on in the same signed-in Chrome. 41 tools, MCP clients that run local servers, MIT.

    Community agent360dev
    robinAKL

    Agent Room

    Put Claude Code, Cursor, Codex, Gemini & Antigravity in one room — real-time multi-agent AI collaboration over MCP for distributed dev, code review, PR handoff & frontend↔backend integration. Free, self-hostable, MCP-native.

    Community robinAKL
    blen-labs

    Capture MCP

    AI-native Model Context Protocol (MCP) server that integrates SAM.gov, USASpending.gov, and Tango APIs to capture and analyze federal procurement and spending data through natural language queries. Responses include both human-readable text and structured JSON so MCP-compatible clients can consume the data programmatically.

    Community blen-labs