Skip to main content
Glama
FastMCP Science Demo

FastMCP Science Demo

by HEP-KE

Science MCP Server Starter

Minimal starter code for wrapping science functions as MCP tools.

The science code stays normal Python. The MCP wrapper only imports the public tool functions listed in pyproject.toml and exposes them through FastMCP.

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

Connect Science Code

  1. Copy the MCP wrapper into the science repo root.

mcp_server/

This repo uses science_demo/ as the example science package.

  1. Create normal Python functions in the science package.

def plot_sine_wave(output_dir: str, num_points: int = 200):
    """Plot a sine wave and save it in output_dir."""
    ...
  1. Export only the MCP tools from the science package __init__.py.

from .science_tools import plot_sine_wave

__all__ = ["plot_sine_wave"]

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

  1. Add the MCP dependency and tool module config in pyproject.toml.

dependencies = [
    "mcp[cli]>=1.27,<2",
]

[tool.mcp-server]
tool_modules = ["your_science_package"]
  1. Install the science repo.

python3.12 -m venv .venv
source .venv/bin/activate
pip install -e .
  1. 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:

{
  "science": {
    "transport": "stdio",
    "command": "python",
    "args": ["-m", "mcp_server", "--transport", "stdio"]
  }
}

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

python -m mcp_server --transport streamable-http --host 127.0.0.1 --port 8000

Then point the agent at:

http://127.0.0.1:8000/mcp

Related MCP server: math-anchor

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

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

Successful artifact tools return:

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

Available Tools

2 tools
generate_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

    A3.7/5.0

    Scored across 2 tools

    Disambiguation5/5

    The two tools have clearly distinct purposes: one generates random point data, the other plots a sine wave. There is no overlap or ambiguity.

    Naming Consistency5/5

    Both tools follow a consistent verb_noun pattern: generate_random_points and plot_sine_wave. The naming is clear and predictable.

    Tool Count3/5

    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.

    Completeness2/5

    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

    ActivityStale
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      B
      maintenance
      Provides a safe scientific runtime for agents with typed math operations including calculus, algebra, statistics, unit conversion, and more via MCP tools.
      4
      Apache 2.0
    • F
      license
      A
      quality
      C
      maintenance
      Enables exposing custom tools such as dice rolling and integer addition as MCP servers over stdio and HTTP transports.
      2
      -
    • F
      license
      Not graded
      quality
      C
      maintenance
      Exposes MCP tools to discover and operate simulated lab devices such as incubators and centrifuges, with read/write access, safety-limit enforcement, and interlock logic.
      -