FastMCP Science Demo
A minimal FastMCP science demo server exposing two artifact-generating tools.
generate_random_points: writes a deterministic CSV of random (x, y) points inoutput_dir; configurablecountandseed.plot_sine_wave: writes a sine wave plot as a PNG inoutput_dir; configurablenum_points.Both tools return structured success results containing output file paths, a message, and metadata.
Intended for simple tutorial/demo workflows; no HPC dispatch or hosted endpoint. (README also mentions
plot_pointsand skills, but the provided schema exposes only these two tools.)
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@FastMCP Science Demo generate 30 random points in /tmp"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Science MCP Server Starter
tutorial · part of the HEP-KE MCP server library
Minimal starter code for wrapping science functions as MCP tools. It is the
smallest complete instance of the HEP-KE MCP server standard: copy it to start
a new server. The science code stays normal Python; the generic MCP wrapper
(mcp_server/) only imports the public tool functions listed in
pyproject.toml and exposes them through FastMCP, together with the
server-side skills in skills/.
This repo only defines the MCP server. Agent code lives in the client repo that connects to it.
At a glance
Category | tutorial |
Domain | none (demo functions) |
HPC dispatch | no (see Add HPC dispatch later) |
Skill prefix |
|
Default port |
|
Hosted endpoint | none |
Related MCP server: math-anchor
Connect Science Code
The whole loop for a new server is: write a function in tools/, list the
module 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)Create normal Python functions in a tool family under
tools/(this repo usestools/demo/). Validate arguments with Pydantic, say in the docstring when to use the tool, write files tooutput_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)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. This
starter does not scan a repo for functions.
List the module in
pyproject.toml(tools.metastays 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"]Add a skill: a markdown file in
skills/whose frontmatternameequals the file stem. Every server ships<prefix>-tour.mdplus at least one science 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) ...Run the tests (
tests/test_contract.pychecks all of the above).
uv sync --extra dev
uv run pytest -m "not network and not slow"
uv run python tests/smoke_server.pyTo start your own server from this one: copy the repo, rename tools/demo/,
change [tool.mcp-server] (name, skill_prefix, a free port, tags) and
mcp_server/INSTRUCTIONS.md, rename skills/demo-tour.md to
skills/<prefix>-tour.md, and update .mcp.json. Keep the generic files
untouched so _standard/sync.py can update them.
Tools
tool | what it does |
| server-side skills (also served as MCP prompts) |
| write a deterministic CSV of (x, y) points in the unit square |
| scatter-plot the x, y columns of a CSV (e.g. the one above) to a PNG |
| 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) -> ArtifactResultThe type hints, docstrings, and Pydantic constraints become the MCP tool schema that 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 that
generate_random_points wrote, not the numbers.
Skills
skill | use it to |
| a one-minute guided run through every tool |
| 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/mcpWithout 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 with
the command and arguments to launch. Claude Code picks up .mcp.json from the
repo directory automatically, or:
claude mcp add demo -- /path/to/science-starter-server/run_server.shA 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 8000Then point the agent at:
http://127.0.0.1:8000/mcpClaude Desktop, Codex, ChatGPT, Antigravity and hep-genesis-agent: see the library site.
demo-notebooks/demo_remote_database_search_mcp.ipynb is a self-contained
walk-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 on
ALCF / NERSC, follow the "HPC dispatch" section of _standard/STANDARD.md in
the MCPs_servers library (reference implementation: supernova-data-server):
Set
hpc = truein[tool.mcp-server]and append"mcp_server.dispatch"last totool_modules.Copy the generic
mcp_server/dispatch.py(_standard/sync.py <dir>does it oncehpc = true). It addsset_dispatch,get_dispatch,auth_statusandexport_dispatch_pack.Move the compute into
tools/<family>/kernels.py: pure functions, JSON-safe arguments in, a JSON-safe dict out, files written to the working directory, importing only numpy/scipy/astropy and declaredpip_deps.Declare them in the family's
__init__.pyasDISPATCH_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 kernel locally otherwise). Mark itfn.weight = "heavy".Add
skills/hpc-dispatch-handoff.md. The contract tests then check the dispatch 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 promptsThe 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 them
per server.
Limitations
The demo tools are deliberately trivial (random points, a sine wave); they exist to show the structure, not to do science. No HPC dispatch, no data registry, no hosted endpoint.
Citation and license
MIT License, see LICENSE. Part of the HEP-KE MCP server library.
Available Tools
2 toolsgenerate_random_pointsA
Generate random point data and save it as a CSV in output_dir.
Use this tool when a workflow needs a small deterministic dataset for
downstream analysis or visualization.
Args:
output_dir: Directory where the CSV should be written.
count: Number of point rows to generate. Must be at least 1.
seed: Seed for deterministic random data.
Inputs: output_dir (required), seed, count. Returns: Success result returned by artifact-producing MCP tools.
plot_sine_waveA
Plot a sine wave and save it as a PNG in output_dir.
Use this tool when a workflow needs a simple generated plot artifact for
downstream inspection or reporting.
Args:
output_dir: Directory where the PNG should be written.
num_points: Number of samples to plot. Must be at least 2.
Inputs: output_dir (required), num_points. Returns: Success result returned by artifact-producing MCP tools.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 2 tools
The two tools have clearly distinct purposes: one generates random point data, the other plots a sine wave. There is no overlap or ambiguity.
Both tools follow a consistent verb_noun pattern: generate_random_points and plot_sine_wave. The naming is clear and predictable.
With only 2 tools, the server feels minimal for a science demo. While it might be intentionally lightweight, it is on the low end of reasonable scope.
The tool set lacks integration between the two capabilities. There is no tool to visualize the random points or generate data for the sine wave plot, leaving a gap in typical scientific workflows.
Maintenance
Related MCP Connectors
Build your own tools from chat: design, test and host them on a shareable MCP server URL.
Call the AI agents you build and test in Backprompter as tools from any MCP client.
Educational MCP server with 17 math/stats tools, visualizations, and persistent workspace
Every app you build or share, and the tools to build more, over one MCP server.
Related MCP Servers
- FlicenseAqualityDmaintenanceEnables Mu2e analysis workflows by exposing event counting, cut analysis, sensitivity computation, and ML selection as MCP tools for agentic frameworks.10-
- AlicenseAqualityBmaintenanceProvides a safe scientific runtime for agents with typed math operations including calculus, algebra, statistics, unit conversion, and more via MCP tools.4Apache 2.0
- FlicenseAqualityDmaintenanceEnables exposing custom tools such as dice rolling and integer addition as MCP servers over stdio and HTTP transports.2-
- AlicenseNot gradedqualityCmaintenanceEnables turning any Python function into an auto-registered MCP tool and serving them over a FastMCP server with auto-discovery, optional auth, and request context.MIT