A Model Context Protocol (MCP) server exposing an HTTP POST endpoint to access data from various open-access data publishers, developed for the EOSC Data Commons project.
It uses a search API, and a Large Language Model (LLM) to help users find the datasets and tools they need.
The HTTP API comprises 2 main endpoints:
-
/mcp
: MCP server that searches for relevant data to answer a user question using the EOSC Data Commons search API- Uses
rmcp
with Streamable HTTP transport - Available tools:
- Search datasets
- Search tools
- Search citations related to datasets or tools
- Uses
-
/search
: simple HTTP POST endpoint (JSON) for querying the MCP server via an LLM provider
Important
Requirements:
- Rust
- API key for a LLM provider: Mistral.ai or OpenAI, you can use the free tier, you just need to login
Recommended VSCode extension: rust-analyzer
rustup update
cargo install cargo-release cargo-deny cargo-watch git-cliff
Create a .cargo/config.toml
file with your Mistral API key or OpenAI API key:
[env]
MISTRAL_API_KEY = "YOUR_API_KEY"
OPENAI_API_KEY = "YOUR_API_KEY"
Start the MCP server in dev at http://localhost:8000/mcp, with OpenAPI UI at http://localhost:8000/docs
cargo run
Customize server configuration through CLI arguments:
cargo run -- --mcp-only --opensearch-url http://localhost:9200
Run and reload on change to the code:
cargo watch -x run
Note
Example curl
request:
curl -X POST http://localhost:8000/search -H "Content-Type: application/json" -H "Authorization: SECRET_KEY" -d '{"messages": [{"role": "user", "content": "data insulin"}], "model": "mistral/mistral-small-latest", "stream": true}'
Recommended model per supported provider:
openai/gpt-4.1
mistral/mistral-large-latest
groq/moonshotai/kimi-k2-instruct
Follow the instructions of your client, and use the /mcp
URL of your deployed server (e.g. http://localhost:8000/mcp)
Add a new MCP server through the VSCode UI:
- Open the Command Palette (
ctrl+shift+p
orcmd+shift+p
) - Search for
MCP: Add Server...
- Choose
HTTP
, and provide the MCP server URL http://localhost:8000/mcp
Your VSCode mcp.json
should look like:
{
"servers": {
"data-commons-mcp-server": {
"url": "http://localhost:8000/mcp",
"type": "http"
}
},
"inputs": []
}
Build binary in target/release/
cargo build --release
Note
Start the server with:
./target/release/data-commons-mcp
Create a keys.env
file with the API keys:
MISTRAL_API_KEY=YOUR_API_KEY
SEARCH_API_KEY=SECRET_KEY_YOU_CAN_USE_IN_FRONTEND_TO_AVOID_SPAM
Tip
SEARCH_API_KEY
can be used to add a layer of protection against bots that might spam the LLM, if not provided no API key will be needed to query the API.
Build and deploy the service:
docker compose up
Automatically format the codebase using rustfmt
:
cargo fmt
Lint with clippy
:
cargo clippy --all
Automatically apply possible fixes:
cargo clippy --fix
Check the dependency supply chain: licenses (only accept dependencies with OSI or FSF approved licenses), and vulnerabilities (CVE advisories).
cargo deny check
Update dependencies in Cargo.lock
:
cargo update
Dry run:
cargo release patch
Or
minor
/major
Create release:
cargo release patch --execute