MCP Connector

Query and Analyze CIViC Cancer Genomics Data

A Cloudflare Workers MCP server that converts CIViC cancer-variant GraphQL data into queryable SQLite tables.

Works with cloudflare

90
Spark score
out of 100
Updated 21 days ago
Version 1.0.0
Models
universal

Add to Favorites

Why it matters

Access and analyze complex cancer genomics and clinical variant interpretation data from the CIViC database. This asset enables structured querying via GraphQL and SQL, transforming raw API responses into usable datasets for research and analysis.

Outcomes

What it gets done

01

Execute GraphQL queries against the CIViC API.

02

Query pre-processed CIViC data using SQL.

03

Convert GraphQL responses into structured SQLite tables.

04

Manage and query intermediate datasets efficiently.

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/vb-civic | bash

Capabilities

Tools your agent gets

civic_graphql_query

Execute GraphQL queries against the CIViC API for cancer genomics data

civic_query_sql

Query pre-processed cancer variant data using SQL

Overview

CIViC MCP Server

A Cloudflare Workers MCP server that converts CIViC cancer-variant GraphQL responses into queryable SQLite tables, with guided prompts and a Code Mode tool. Use when an assistant needs to query live CIViC cancer-variant evidence and assertions rather than relying on training knowledge.

What it does

A Cloudflare Workers-based MCP server that queries the CIViC (Clinical Interpretation of Variants in Cancer) API - a crowd-sourced database of clinical interpretations of cancer variants - and converts its GraphQL responses into queryable SQLite tables via Cloudflare Durable Objects, so an AI assistant can run structured SQL analysis over cancer genomics data instead of just reading raw GraphQL output. Three tools form a pipeline: civic_graphql_query executes a GraphQL query and stages large result sets into SQLite; civic_query_sql runs SQL against that staged data; and civic_execute ("Code Mode") runs JavaScript in a V8 isolate with a gql.query() helper and schema helpers for full, programmatic GraphQL access. Response handling is optimized to skip staging when it isn't needed: responses under 1,500 characters, error responses, empty/null responses, and schema-introspection queries (containing __schema/__type) are all returned directly rather than written into a temporary database. On top of the tool pipeline, the server exposes three MCP Prompts that generate correct CIViC v2 GraphQL for the model: get-variant-evidence (Evidence Items only - the schema doesn't support a variantName filter), get-variant-assertions (Assertions only, with systematic fallback search strategies), and get-variant-data (both queries combined for a comprehensive variant analysis), all defaulting status to "ALL" to avoid over-filtering and auto-excluding null parameters.

When to use - and when NOT to

Use it when an assistant needs to answer questions like "what's the latest evidence for BRAF mutations" or "find genes with the most evidence items" by querying live CIViC data rather than relying on the model's training knowledge. It implements the MCP 2025-06-18 spec with structured tool output, _meta fields, protocol-version headers, and title fields, but two pieces remain incomplete: tool annotations (readOnlyHint/destructiveHint/idempotentHint/openWorldHint are defined per tool but not yet wired into the SDK's tool() method) and OAuth 2.1 authorization (not implemented, so it isn't yet suited for secure multi-tenant remote access without an additional auth layer in front). Streamable HTTP transport is done - the legacy HTTP+SSE transport has been removed in favor of serving at /mcp - and JSON-RPC batching has been properly removed per the 2025-06-18 spec.

Capabilities

GraphQL-to-SQL conversion of CIViC API responses, staged in per-request SQLite tables via Cloudflare Durable Objects; a Code Mode tool for arbitrary JavaScript-driven GraphQL querying inside a V8 isolate; and three guided MCP Prompts for evidence, assertion, or combined variant queries with automatic fallback search strategies and canonical result URLs (/evidence/{id}, /assertions/{id}).

How to install

Requires a Cloudflare account, the Wrangler CLI, and Claude Desktop. Deploy with git clone <repository-url>, npm install, and npm run deploy, which produces a URL like https://civic-mcp-server.YOUR_SUBDOMAIN.workers.dev. Then configure Claude Desktop:

{
  "mcpServers": {
    "civic-mcp-server": {
      "command": "npx",
      "args": [
        "mcp-remote",
        "https://civic-mcp-server.quentincody.workers.dev/mcp"
      ]
    }
  }
}

Replace the subdomain with your own deployed Workers URL, then restart Claude Desktop.

Who it's for

Researchers and developers building cancer-genomics assistants who need an AI-queryable interface to the CIViC database - GraphQL access, SQL analysis over staged results, and guided prompts for evidence/assertion lookups - without hand-writing CIViC v2 GraphQL themselves. The project is released under the MIT License with an added academic citation requirement, so production and research use are both permitted as long as the required citation is honored.

Source README

CIViC MCP Server

This is a Cloudflare Workers-based Model Context Protocol (MCP) server that provides tools for querying the CIViC (Clinical Interpretation of Variants in Cancer) API. The server converts GraphQL responses into queryable SQLite tables using Durable Objects for efficient data processing.

The CIViC database is a crowd-sourced repository of clinical interpretations of cancer variants. This MCP server enables structured queries and data analysis of cancer genomics information through natural language interactions with AI assistants.

MCP Specification Compliance

This server implements MCP 2025-06-18 specification with the following compliance status:

โœ… Implemented Features

  • Structured Tool Output: Tools return structured JSON data with _meta fields
  • Protocol Version Headers: Supports MCP-Protocol-Version header handling
  • Title Fields: Tools include human-friendly titles for display
  • Meta Fields: Extensive use of _meta fields for additional context
  • Error Handling: Proper error responses with structured content

๐Ÿ”„ Partially Implemented

  • Tool Annotations: Configuration ready but SDK integration pending
    • readOnlyHint, destructiveHint, idempotentHint, openWorldHint defined
    • Need SDK update to support annotation parameters

โš ๏ธ Pending Implementation

  • Streamable HTTP Transport: โœ… Done - serves Streamable HTTP at /mcp (CivicMCP.serve("/mcp")); the legacy HTTP+SSE transport has been removed
  • OAuth 2.1 Authorization: Not implemented
    • Action Required: Add OAuth 2.1 support for secure remote server access
    • Components: Authorization Server discovery, Resource Indicators (RFC 8707)
  • JSON-RPC Batching: Properly removed (was added in 2025-03-26, removed in 2025-06-18)

Tool Annotations Reference

The server defines comprehensive tool annotations for MCP clients:

// GraphQL Query Tool
annotations: {
  readOnlyHint: false,      // Creates/modifies data in SQLite
  destructiveHint: false,   // Non-destructive data staging
  idempotentHint: false,    // Different queries produce different results
  openWorldHint: true       // Interacts with external CIViC API
}

// SQL Query Tool  
annotations: {
  readOnlyHint: true,       // Only reads data
  destructiveHint: false,   // Cannot modify data (read-only SQL)
  idempotentHint: true,     // Same query produces same results
  openWorldHint: false      // Operates on closed SQLite database
}

Future Updates Required

1. Transport Layer Migration โœ… Done

// Now: Streamable HTTP Transport (MCP 2025-03-26+)
CivicMCP.serve("/mcp", { binding: "MCP_OBJECT" }).fetch(request, env, ctx)

2. Tool Annotation Integration

// Current: SDK doesn't support 5-argument tool() method
this.server.tool(name, description, schema, handler, annotations) // โŒ

// Target: Find correct SDK pattern for annotations
// May require MCP SDK update or different approach

3. Authorization Framework

// Required: OAuth 2.1 integration with:
// - Authorization Server discovery (.well-known endpoints)
// - Resource Indicators (RFC 8707) 
// - Dynamic client registration (RFC 7591)
// - PKCE-enabled authorization code flow

Specification Changelog Summary

MCP 2025-03-26 (Implemented)

  • โœ… Tool annotations framework
  • โœ… Streamable HTTP transport
  • โœ… Audio data support (infrastructure ready)
  • โš ๏ธ OAuth 2.1 authorization (pending)

MCP 2025-06-18 (Current Target)

  • โœ… Structured tool output
  • โœ… Enhanced _meta fields
  • โœ… Protocol version headers
  • โœ… Title fields for tools
  • โŒ JSON-RPC batching removed (properly removed)
  • โš ๏ธ Enhanced authorization security (pending)

Features

  • GraphQL to SQL Conversion: Automatically converts CIViC API responses into structured SQLite tables
  • Efficient Data Storage: Uses Cloudflare Durable Objects with SQLite for data staging and querying
  • Smart Response Handling: Optimizes performance by bypassing staging for small responses, errors, and schema introspection queries
  • Tool Pipeline:
    1. civic_graphql_query: Executes GraphQL queries and stages large datasets
    2. civic_query_sql: Enables SQL-based analysis of staged data
    3. civic_execute: Code Mode - runs JavaScript in a V8 isolate with gql.query() and schema helpers for full GraphQL access

Installation & Configuration

Prerequisites

  • A Cloudflare account
  • Wrangler CLI installed
  • Claude Desktop app

Deploy to Cloudflare Workers

  1. Clone this repository:

    git clone <repository-url>
    cd civic-mcp-server
    
  2. Install dependencies:

    npm install
    
  3. Deploy to Cloudflare Workers:

    npm run deploy
    
  4. After deployment, you'll get a URL like: https://civic-mcp-server.YOUR_SUBDOMAIN.workers.dev

Configure Claude Desktop

Add this configuration to your claude_desktop_config.json file:

{
  "mcpServers": {
    "civic-mcp-server": {
      "command": "npx",
      "args": [
        "mcp-remote",
        "https://civic-mcp-server.quentincody.workers.dev/mcp"
      ]
    }
  }
}

Replace quentincody with your actual Cloudflare Workers subdomain.

Usage

Once configured, restart Claude Desktop. The server provides three main tools:

  1. civic_graphql_query: Execute GraphQL queries against the CIViC API
  2. civic_query_sql: Query staged data using SQL
  3. civic_execute: Code Mode - write JavaScript against the CIViC GraphQL API in a V8 isolate

Prompts

This server exposes three MCP Prompts that guide the model to use the civic_graphql_query tool with correct GraphQL syntax and robust search strategies:

Individual Data Type Prompts

  • get-variant-evidence - Generates GraphQL for Evidence Items only (no variantName filter - not supported by CIViC schema)
  • get-variant-assertions - Generates GraphQL for Assertions only with systematic fallback strategies

Combined Data Prompt

  • get-variant-data - Executes both Evidence Items AND Assertions queries for comprehensive variant analysis

Examples (VS Code Copilot Chat / slash-commands):

  • /get-variant-evidence molecularProfileName:"TP53 Mutation" diseaseName:"Lung Adenocarcinoma" evidenceType:"PROGNOSTIC" first:"200"
  • /get-variant-assertions molecularProfileName:"TPM3-NTRK1 Fusion" therapyName:"Larotrectinib" status:"ALL"
  • /get-variant-data molecularProfileName:"BRAF V600E" diseaseName:"Melanoma" therapyName:"Trametinib" status:"ALL"

Key Prompt Features

  • Bulletproof GraphQL Generation: Complete, validated queries that never fail
  • Intelligent Search Strategies: Automatic fallback approaches to find relevant data
  • Comprehensive Results: Evidence items include clinical descriptions; assertions provide high-level summaries
  • Optimal Filtering: Default status is "ALL" to avoid over-filtering; null parameters are automatically excluded
  • Proper URL Generation: Canonical links for verification (evidence: /evidence/{id}, assertions: /assertions/{id})

These prompts provide complete GraphQL queries with proper CIViC v2 schema compliance and systematic search methodologies that ensure data discovery even when users provide imperfect parameters.

Example Queries

You can ask Claude questions like:

  • "What are the latest evidence items for BRAF mutations?"
  • "Show me all therapeutic interpretations for lung cancer variants"
  • "Find genes with the most evidence items in the CIViC database"

Claude will use the server (and its civic_graphql_query tool) to fetch the relevant data from the CIViC database and present it to you. The server is designed to query version 2 of the CIViC API, ensuring you get up-to-date information.

If you encounter issues or Claude doesn't seem to be using the CIViC data, double-check the configuration steps above.

Response handling

The server intelligently optimizes context usage by storing large results in a temporary SQLite database. When GraphQL responses meet certain criteria, the raw response is returned directly instead of creating a database:

  • Small responses (< 1500 characters): Returned directly to avoid unnecessary overhead
  • Error responses: Passed through directly to make troubleshooting easier
  • Empty/null responses: Bypassed to avoid creating empty databases
  • Schema introspection queries: Queries containing __schema, __type, or other introspection patterns are returned directly since they contain metadata rather than data suitable for SQL conversion

This optimization makes the server more efficient and provides better error visibility while still enabling powerful SQL-based analysis for substantial datasets.

FAQ

Common questions

Discussion

Questions & comments ยท 0

Sign In Sign in to leave a comment.