Skip to main content

Connect a custom MCP tool

Worked example Query a public QC table through a local MCP server

This example exposes an existing public RNA-seq QC table through a small local MCP server. It reads a fixed CSV and offers two operations; it does not query the network, install packages or modify the dataset.

Platform
Your choice is kept across chapters.

Download the actual example

Save both files locally and note their full paths. The server uses Python's standard library. It reads the selected CSV at startup, so restart/reconnect it deliberately if you replace that input.

Add it in Open-Science

  1. Open Settings → Connectors → Add connector → Local command.
  2. Set Display name to GSE60450 QC.
  3. Choose python3 — script file as Command, or Other… with the actual Python executable path on Windows.
  4. Open Advanced settings. Set the connector name/ID to gse60450-qc and describe it as read-only access to the saved QC table.
  5. In Arguments, put the script's absolute path on the first line and the CSV's absolute path on the second. Each line is a single argument. Do not add shell quotes around a path merely because it contains spaces.
  6. Leave Environment empty for this example. Review the server script, check I trust this connector, then Add.
  7. Search GSE60450 and confirm Connected and availability to Main Agent.

Actual local MCP configuration

/absolute/path/qc-mcp-server.py
/absolute/path/rnaseq-sample-qc.csv

These two lines are a path template, not literal paths to paste unchanged. If python3 is unavailable to the app, choose Other and the actual executable path. The selected launcher must exist on this computer.

Tool inputs and verified outputs

ToolInputActual expected content
get_dataset_summaryEmpty objectGSE60450, source URL, input filename, 12 rows and full sample identifiers
get_sample_qcsample_id stringThe selected sample's four numeric QC metrics

Ask the agent:

Use the connected gse60450-qc Connector. Call get_dataset_summary, then get_sample_qc for MCL1-DG_BC2CTUACXX_ACTTGA_L002_R1. Report only actual responses and preserve the CSV.

In this example, the native application returned 23,227,641 total counts, 8,664 zero-count genes, 18,515 detected genes and median 237 for that sample. The dataset-summary call returned 12 rows. These match the original saved QC table.

The custom Connector connected successfully

Inspect the server and error behavior

The server implements MCP initialize, ping, tool discovery and calls over stdio. Its two tool schemas are defined in the downloadable script. Standard output is the protocol channel; adding ordinary debug prints there can break the connection. Local diagnostics belong on standard error.

Known error mapping: an invalid sample name can surface as connector_unavailable in the app even when the custom server returns a domain-specific error. Check the server log and validate the sample identifier before reconnecting. Report persistent mismatches using Troubleshooting.

Do not invoke protocol tools/list as a business tool through host.mcp; the application already discovers the server's tools during connection. The attempted gse60450-qc/tools/list call was rejected as unknown tool. Use the discovered operation names or inspect the server's own schema.

Export and move to another computer

Choose the row's Actions → Export, select the desired format and inspect the configuration preview. The real export warned that both argument paths were local. Save configuration exports the settings, not the Python interpreter, script or CSV. Copy those files separately, update paths, confirm local trust and repeat both successful calls.

FailureCheck
Command cannot startExecutable path, script path and file permissions
CSV cannot be readSecond argument and actual file location
Connected but tool unavailableAgent assignment, current catalog and exact tool name
Bad inputRequired sample_id and the original full identifier, not the compact plot label
Connector error after a failed callInspect server/application error details and reconnect when appropriate
Works in a terminal but not the appApp-visible executable/environment and protocol-only stdout

To extend the example, define a small input schema, return source identifiers and test normal, empty and invalid inputs before exposing the tool. Keep these operations narrow enough that a user can inspect what the call will read or change.

Implementation reference: ConnectorAddForm.tsx, service.ts.

For managing the same custom MCP configuration from scripts, use Connector CLI commands or SDK methods. A successful connection test discovers tools; verify a separate bounded business call before calling the integration operational.