Skip to content

๐Ÿ”ญ Model Context Protocol (MCP) server with an HTTP API endpoint to access data from various open access data publishers

License

Notifications You must be signed in to change notification settings

EOSC-Data-Commons/data-commons-mcp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

31 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ”ญ EOSC Data Commons MCP server

Tests

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.

๐Ÿงฉ Endpoints

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
  • /search: simple HTTP POST endpoint (JSON) for querying the MCP server via an LLM provider

    • Uses axum, utoipa for OpenAPI spec generation, llm to interact with LLM providers (e.g. Mistral, OpenAI)
    • Returns a streaming response: tool call requested, then tool call results, and final search results.

๐Ÿ› ๏ธ Development

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

๐Ÿ“ฅ Install dev dependencies

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 dev server

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

๐Ÿ”Œ Connect MCP client

Follow the instructions of your client, and use the /mcp URL of your deployed server (e.g. http://localhost:8000/mcp)

๐Ÿ™ VSCode GitHub Copilot

Add a new MCP server through the VSCode UI:

  • Open the Command Palette (ctrl+shift+p or cmd+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 for production

Build binary in target/release/

cargo build --release

Note

Start the server with:

./target/release/data-commons-mcp

๐Ÿณ Deploy with Docker

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

๐Ÿงผ Format & lint

Automatically format the codebase using rustfmt:

cargo fmt

Lint with clippy:

cargo clippy --all

Automatically apply possible fixes:

cargo clippy --fix

โ›“๏ธ Check supply chain

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

๐Ÿท๏ธ Release

Dry run:

cargo release patch

Or minor / major

Create release:

cargo release patch --execute

About

๐Ÿ”ญ Model Context Protocol (MCP) server with an HTTP API endpoint to access data from various open access data publishers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •