A Model Context Protocol (MCP) server for interacting with VirtualFlyBrain (VFB) APIs. This server provides tools to query VFB data, run queries, and search for terms. In HTTP mode it runs statelessly (no session tracking), so any replica can handle any request and standard load balancing works.
The easiest way to use VFB3-MCP is through our hosted service at https://vfb3-mcp.virtualflybrain.org. This requires no installation or setup on your machine.
- Open Claude Desktop and go to Settings
- Navigate to the MCP section
- Add a new MCP server with these settings:
- Server Name:
virtual-fly-brain(or any name you prefer) - Type: HTTP
- Server URL:
https://vfb3-mcp.virtualflybrain.org
- Server Name:
Configuration JSON (alternative method):
{
"mcpServers": {
"virtual-fly-brain": {
"type": "http",
"url": "https://vfb3-mcp.virtualflybrain.org",
"tools": ["*"]
}
}
}-
Locate your Claude configuration file:
- macOS/Linux:
~/.claude.json - Windows:
%USERPROFILE%\.claude.json
- macOS/Linux:
-
Add the VFB3-MCP server to your configuration:
{
"mcpServers": {
"virtual-fly-brain": {
"type": "http",
"url": "https://vfb3-mcp.virtualflybrain.org",
"tools": ["*"]
}
}
}- Restart Claude Code for changes to take effect
- Open VS Code with GitHub Copilot installed
- Open Settings (
Ctrl/Cmd + ,) - Search for "MCP" in the settings search
- Find the MCP Servers setting
- Add the server URL:
https://vfb3-mcp.virtualflybrain.org - Give it a name like "Virtual Fly Brain"
Alternative JSON configuration (in mcp.json):
{
"servers": {
"virtual-fly-brain": {
"type": "http",
"url": "https://vfb3-mcp.virtualflybrain.org"
}
}
}- Install the MCP extension for VS Code from the marketplace
- Open the Command Palette (
Ctrl/Cmd + Shift + P) - Type "MCP: Add server" and select it
- Choose "HTTP" as the server type
- Enter the server details:
- Name:
virtual-fly-brain - URL:
https://vfb3-mcp.virtualflybrain.org
- Name:
- Save and restart VS Code if prompted
For any MCP-compatible client that supports HTTP servers:
{
"mcpServers": {
"virtual-fly-brain": {
"type": "http",
"url": "https://vfb3-mcp.virtualflybrain.org",
"tools": ["*"]
}
}
}To use the Virtual Fly Brain (VFB) Model Context Protocol (MCP) server with Google Gemini, you can connect through custom Python/Node.js clients that support MCP.
Note: Direct Gemini web interface integration with MCP is not currently supported. Developer tools are needed to connect the two.
Option 1: Using Python
For application development, use the mcp and google-genai libraries to connect.
Setup: pip install google-genai mcp
Implementation: Use a streamable HTTP transport in JSON response mode (e.g. enableJsonResponse: true) to connect to the VFB URL, list its tools, and pass their schemas to the Gemini model as Function Declarations.
Once configured, you can test that VFB3-MCP is working by asking your AI assistant questions like:
Basic Queries:
- "Get information about the neuron VFB_jrcv0i43"
- "Search for terms related to medulla in the fly brain"
- "What neurons are in the antennal lobe?"
Advanced Queries:
- "Find all neurons that connect to the mushroom body"
- "Show me expression patterns for gene repo"
- "What brain regions are involved in olfactory processing?"
- "Run a connectivity analysis for neuron VFB_00101567"
Search Examples:
- "Search for adult neurons in the visual system"
- "Find genes expressed in the central complex"
- "Show me all templates available in VFB"
If you see responses with VirtualFlyBrain data, including neuron names, brain regions, gene expressions, or connectivity information, the setup is successful!
For more detailed usage examples and API calls, see examples.md.
- Search for a term: "Search for neurons in the optic lobe"
- Get detailed info: "Get information about VFB_00101567"
- Run specific queries: "Show connectivity for VFB_00101567"
- Explore relationships: "What neurons synapse in the mushroom body?"
The MCP server exposes the following tools (available to assistants like Claude and Copilot):
get_term_infoβ Get detailed metadata for a VFB IDrun_queryβ Run a precomputed analysis query for a VFB ID (see theQueriesfield fromget_term_info)search_termsβ Search VFB entities by text with filtering / boosting options. This is the same search virtualflybrain.org itself runslist_search_facetsβ List thefacets_annotationtype names thatsearch_terms'filter_types/exclude_types/boost_types/demote_typesaccept, optionally filtered by substringresolve_entityβ Resolve an unresolved FlyBase-related query string (e.g.,P{VT054895-GAL4.DBD}or a driver line / cell type label) to VFB/FlyBase IDs and metadata (not the same as VFB term search)resolve_combinationβ Resolve an unresolved split-GAL4 combination name or synonym into its component IDslist_connectome_datasetsβ List available connectome datasets (e.g., Hemibrain, FAFB)query_connectivityβ Query connectivity across connectome datasets using upstream/downstream filters, returned as a strongest-first page plus a summary computed over every connection foundget_hierarchyβ Traverse the ontology hierarchy for a VFB ID:part_of(region/tissue structure) and/orsubclass_of(cell-type taxonomy), ancestors and/or descendants
- Node.js 18 or higher
- npm or yarn
-
Clone the repository:
git clone https://github.com/Robbie1977/VFB3-MCP.git cd VFB3-MCP -
Install dependencies:
npm install
-
Build the project:
npm run build
-
Start the server:
npm start
For local development with Claude Desktop, add this to your MCP configuration:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"vfb3-mcp": {
"command": "node",
"args": ["/absolute/path/to/VFB3-MCP/dist/index.js"]
}
}
}Add to your claude.json file:
{
"mcpServers": {
"vfb3-mcp": {
"command": "node",
"args": ["/absolute/path/to/VFB3-MCP/dist/index.js"]
}
}
}- Install the MCP extension for VS Code
- Press
Cmd + Shift + P(macOS) orCtrl + Shift + P(Windows/Linux) - Select MCP: Add serverβ¦
- Choose Command type
- Enter:
- Name:
vfb3-mcp - Command:
node - Arguments:
/absolute/path/to/VFB3-MCP/dist/index.js
- Name:
Configure the MCP server URL in your Copilot settings to point to your local server:
http://localhost:3000
For HTTP mode testing:
MCP_MODE=http PORT=3000 node dist/index.jsUsing Docker Compose (Recommended):
docker-compose up --buildManual Docker Build:
# Build the image
docker build -t vfb3-mcp .
# Run the container
docker run -p 3000:3000 vfb3-mcpPull Pre-built Image:
docker pull virtualflybrain/vfb3-mcp:latest
docker run -p 3000:3000 virtualflybrain/vfb3-mcp:latestRetrieve detailed information about VFB terms using their IDs.
Parameters:
id(string): VFB ID (e.g., "VFB_jrcv0i43")force_refresh(boolean, optional): Bypass the response cache and recompute (seerun_querybelow for the cost and the whitelisting caveat)
Execute predefined queries on VFB data.
Parameters:
id(string or array): One or more VFB IDs (e.g., "VFB_00101567")query_type(string): Query type from the entity'sQueriesarray (e.g., "PaintedDomains")queries(array, optional):{id, query_type}pairs for mixed batch querieslimit(number, optional): Max rows per call (default 25). The true total is always returned ascount; use 0 for all rows (still capped ~25000)offset(number, optional): Row offset for paging (default 0); re-run withoffset += limitfor the next pageinclude_images(boolean, optional): Include thethumbnailcolumn (default false β it is stripped to save space, and the response_notesays how to re-add it)force_refresh(boolean, optional): Bypass the response cache and recompute. Expensive; intended only as a one-shot retry of a call that returned a stale or failed result. A failed query is already retried once automatically. Requires the server's egress IP to be whitelisted on v3-cached β from a non-whitelisted host nginx ignores the header and serves the cached entry unchanged.
The response reports count_status alongside count: exact (count is the true total), row_count (no total supplied β count is just the rows returned), or unavailable (the query failed upstream and count is -1). A -1 is an error indication, not an empty result set, and _note says so in words.
FlyBase stocks and split-GAL4 combination publications are run_query query_types too: FindStocks and FindComboPublications.
Search for VFB terms. This calls VFBquery's /search, which is the search virtualflybrain.org itself runs β the same Solr query, the same filters and boosts, the same final sort β so a result here is the result a user would see on the site. Deprecated terms are already excluded server-side; there is no need to ask for that.
Parameters:
query(string): Search query (e.g., "medulla")filter_types(array, optional): Keep only results matching ALL of these facets_annotation types (AND logic)exclude_types(array, optional): Drop results matching ANY of these facets_annotation types (OR logic)boost_types(array, optional): Lift results matching these types up the ranking without excluding othersdemote_types(array, optional): Sink results matching these types to the bottom of the ranking without excluding them. Ignored for a type that also appears inboost_typesunique(boolean, optional): One row per term (default true). Set false for one row per matching synonym, which shows which name matched at the cost of repeating IDsstart(number, optional): Page start index (default 0)rows(number, optional): Rows to return (default 150, max 1000)minimize_results(boolean, optional): Return only the top 10 with reduced fields, for a first look (default false)auto_fetch_term_info(boolean, optional): When the query matches one term's name exactly, also fetch that term's info (default false)
Type names come from the live vocabulary β there are over 200 of them and they change as data is added, so call list_search_facets rather than guessing. The response reports returned (rows given), total (length of the ranked list), distinct_terms and solr_matches (terms Solr matched before ranking) separately, so a truncated page never looks like a small result set.
List the valid facets_annotation type names for the four type filters above, read from the live vocabulary.
Parameters:
contains(string, optional): Case- and separator-insensitive substring filter (e.g., "neuron", "nervous system")
If the deployed VFBquery predates the /facets endpoint, this falls back to a snapshot bundled with the server and says so β names absent from a snapshot result may still be valid.
Query synaptic connectivity between neuron classes across all connectome datasets. At least one of upstream_type or downstream_type is required. Results are ranked strongest-first and paged: you get limit rows plus a summary computed over every connection found β weight min/max/total/mean, per-dataset counts, distinct neuron counts, and the top class pairs β so the totals stay true even though the rows are truncated. A broad query can find tens of thousands of connections, which is why paging is on by default.
Parameters:
upstream_type/downstream_type(string, optional): Neuron class OWL ID or label. Anatomical regions are not acceptedweight(number, optional): Minimum synapse count (recommended 5; use β₯50 when both ends are specified)group_by_class(boolean, optional): Aggregate to class pairs instead of neuron pairs β usually the better first call on a broad queryexclude_dbs(array, optional): Dataset symbols to exclude (recommended["hb","fafb"]); seelist_connectome_datasetslimit(number, optional): Rows to return, strongest first (default 50;0for all)offset(number, optional): Row to start from within the ranking (default 0)
VirtualFlyBrain (VFB) is a comprehensive knowledge base about Drosophila melanogaster neurobiology, providing 3D images, gene expression data, neural connectivity information, and standardized terminology for fly brain research.
- LLM Guidance: Guide for AI assistants on using this MCP effectively
- Examples: Usage examples and integration guides
- Technical Documentation: Infrastructure, deployment, and development details
MIT