Skip to content

MCP server for UCSF BioRouter to query the MSBase database

Notifications You must be signed in to change notification settings

BaranziniLab/MSBaseAgent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

MSBaseAgent

An MCP (Model Context Protocol) server for querying the UCSF Multiple Sclerosis medical database for rapid clinical data retrieval.

Features

  • Query MS Database: Execute SQL queries on the UCSF Multiple Sclerosis medical database
  • List Available Tables: Discover all available clinical data tables with schema information
  • Pre-configured Access: All database connection parameters are pre-configured - no setup required!
  • Read-Only Security: Only SELECT, SHOW, DESCRIBE, and EXPLAIN queries allowed

Installation

From GitHub (using uvx)

uvx --from git+https://github.com/BaranziniLab/MSBaseAgent msbaseagent

Local Installation

cd MSBaseAgent
pip install -e .

Usage

As an MCP Server

Add to your MCP client configuration (e.g., Claude Desktop):

{
  "mcpServers": {
    "msbaseagent": {
      "command": "uvx",
      "args": ["--from", "git+https://github.com/BaranziniLab/MSBaseAgent", "msbaseagent"]
    }
  }
}

Direct Command Line

msbaseagent

Configuration

All database connection parameters are pre-configured:

  • Server: queryms.ucsf.edu
  • Port: 3306
  • Username: medcp
  • Password: Medcp_aiqueries_123#@!
  • Database: imsms
  • Namespace: MSAgent

No additional configuration is required!

Optional environment variable:

  • MSBASE_LOG_LEVEL: Set logging level (DEBUG, INFO, WARNING, ERROR) - defaults to INFO

Available Tools

1. MSAgent-list_tables

List all tables in the MySQL database with their columns and data types.

Parameters:

  • database (string, optional): Database name to list tables from (defaults to "imsms")

Example: Returns comprehensive schema information including table structure, column names, data types, constraints, and row counts.

2. MSAgent-execute_query

Execute a READ-ONLY SQL query on the UCSF MS medical database.

Parameters:

  • query (string, required): SQL SELECT query to execute
  • database (string, optional): Database name to execute query against (defaults to "imsms")

Example:

SELECT COUNT(*) FROM patients WHERE diagnosis_date > '2023-01-01'

Security

This server enforces read-only access to the MS database. Write operations (INSERT, UPDATE, DELETE, CREATE, DROP, ALTER, TRUNCATE, etc.) are not permitted.

Important:

  • Only SELECT, SHOW, DESCRIBE, and EXPLAIN queries are allowed
  • The database contains de-identified patient data
  • Follow all UCSF data use policies and HIPAA regulations

Network Requirements

  • UCSF Network Access: Must be connected to UCSF network or VPN
  • Port 3306: MySQL port must be accessible
  • DNS Resolution: Must be able to resolve queryms.ucsf.edu

Database Structure

The UCSF MS medical database contains clinical research data related to Multiple Sclerosis patients, including:

  • Patient demographics
  • Clinical assessments
  • Treatment records
  • Disease progression markers
  • Lab results
  • Imaging data

Use the MSAgent-list_tables tool to explore the complete database schema.

Troubleshooting

Database Connection Failed

  • Check UCSF VPN connection
  • Verify network connectivity to queryms.ucsf.edu
  • Ensure port 3306 is accessible

Permission Denied

  • Verify you are connected to UCSF network or VPN
  • Check if database server is accessible
  • Contact UCSF IT if issues persist

Query Errors

  • Use MSAgent-list_tables to verify table and column names
  • Check SQL syntax
  • Ensure query is read-only (SELECT statements only)

License

MIT

Author

Wanjun Gu

About

MSBaseAgent is designed specifically for authorized medical research personnel at UCSF working with Multiple Sclerosis clinical data. It provides secure, read-only access to clinical databases for research analysis and data exploration.

Acknowledgments

  • UCSF Multiple Sclerosis Center for database access
  • Model Context Protocol (MCP) community
  • FastMCP framework

About

MCP server for UCSF BioRouter to query the MSBase database

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages