About fhir-mcp-server-medagentbench
fhir-mcp-server-medagentbench is a Python MCP server for testing MedAgentBench agents without a live FHIR endpoint. It simulates FHIR operations and returns text describing the HTTP requests that would have been sent.
Key features
- 01Simulate FHIR searches and reads
- 02Simulate FHIR resource creation
- 03Return representations of HTTP requests
- 04Expose simulated resources and tools
Use cases
- 01Test MedAgentBench agents without a live FHIR API
- 02Inspect generated FHIR request representations
MCP support
The server exposes simulated FHIR resources and tools to MCP clients, including search, read, and resource-creation operations. It returns textual representations rather than sending HTTP requests to a FHIR server.
Configuration
Local server config is the same for every client. Copy it into your client’s MCP config file.
We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.
Tools
Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.
Details
From the project READMEfhir-mcp-server-medagentbench
A Python-based MCP (MedAgentBench Communications Protocol) server designed for the MedAgentBench environment. This server simulates interactions with a FHIR (Fast Healthcare Interoperability Resources) API.
Instead of making actual HTTP requests to a FHIR server, it intercepts MCP requests for FHIR operations and returns a textual representation of the HTTP request that would have been made (e.g., GET https://fhir.example.com/Patient/123 or POST https://fhir.example.com/Observation\n{...}). This allows testing MedAgentBench agents without needing a live FHIR endpoint.
Features
- Implements MCP handlers:
list_resources: Lists available simulated resources (currentlyCapabilityStatement).read_resource: Simulates reading a FHIR resource by its URI.list_tools: Lists available FHIR simulation tools.call_tool: Simulates executing FHIR operations:search_fhir: Simulates searching for FHIR resources.read_fhir: Simulates reading a specific FHIR resource by URI.create_fhir_resource: Simulates creating a new FHIR resource.
- Uses
mcp-serverlibrary for MCP communication. - Configured and packaged using Poetry.
- Includes asynchronous unit tests with
pytestandpytest-asyncio.
Installation
Ensure you have Python >= 3.10 and Poetry installed.
poetry install
Configuration
Before running the server, you must set the FHIR_BASE_URL environment variable. This URL is used to construct the simulated request strings.
export FHIR_BASE_URL="https://your-fhir-server-base.com/fhir"
# Or for local testing:
# export FHIR_BASE_URL="http://localhost:8080/fhir"
Usage
Once configured, run the server using the installed script:
fhir-mcp-server-medagentbench
The server will start listening for MCP requests over standard input/output.
Development
Setup
Clone the repository and install dependencies, including development tools:
git clone https://github.com/MikeHolcomb/mcp-fhir-python-medagentbench.git
cd mcp-fhir-python-medagentbench
poetry install --with dev
Linting and Formatting
This project uses pre-commit to enforce code style (black, isort) and check for issues (flake8, mypy).
# Run all checks on staged files (usually run automatically on commit)
poetry run pre-commit run
# Run all checks on all files
poetry run pre-commit run --all-files
# Or run tools individually
poetry run black .
poetry run isort .
poetry run flake8 src tests
poetry run mypy src
Testing
Tests are located in the tests/ directory and use pytest.
poetry run pytest
# Run with coverage report
poetry run pytest --cov=src
Tests require pytest-asyncio due to the asynchronous nature of the MCP handlers.
License
This project is licensed under the MIT License - see the LICENSE file for details (though a LICENSE file might need to be created if not present).
Contributing
Contributions are welcome! Please open an issue or submit a pull request.
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.