Synapse MCP Server

by susheel
Verified
MIT License
  • Linux
  • Apple

Integrations

  • Enables cloning the source code repository from GitHub for installation and development.

  • Allows installing the Synapse MCP server package directly from PyPI repository.

  • Supports running tests for the Synapse MCP server using the pytest framework.

Servidor Synapse MCP

Un servidor de Protocolo de Contexto de Modelo (MCP) que expone entidades de Synapse (conjuntos de datos, proyectos, carpetas, archivos, tablas) con sus anotaciones.

Descripción general

Este servidor proporciona una API RESTful para acceder a las entidades de Synapse y sus anotaciones mediante el Protocolo de Contexto de Modelo (MCP). Permite:

  • Autenticarse con Synapse
  • Recuperar entidades por ID
  • Obtener anotaciones de entidades
  • Obtener entidades hijas
  • Consultar entidades en función de varios criterios
  • Consultar tablas de Synapse

Instalación

# Clone the repository git clone https://github.com/SageBionetworks/synapse-mcp.git cd synapse-mcp # Create a virtual environment python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate # Install dependencies pip install -e .

Instalación desde PyPI

# Install from PyPI pip install synapse-mcp

Uso

Iniciando el servidor

python server.py

Esto iniciará el servidor MCP en el puerto predeterminado (9000).

Usando la CLI

# Start the server using the CLI synapse-mcp --host 127.0.0.1 --port 9000 --debug

Opciones de la línea de comandos

usage: server.py [-h] [--host HOST] [--port PORT] [--debug] Run the Synapse MCP server options: -h, --help show this help message and exit --host HOST Host to bind to --port PORT Port to listen on --debug Enable debug logging

Ejecución de pruebas

# Run all tests with coverage ./run_tests.sh # Or run pytest directly python -m pytest

Probando el servidor

python examples/client_example.py

Puntos finales de API

Información del servidor

  • GET /info - Obtener información del servidor

Herramientas

  • GET /tools - Lista de herramientas disponibles
  • POST /tools/authenticate - Autenticarse con Synapse
  • POST /tools/get_entity - Obtener una entidad por ID
  • POST /tools/get_entity_annotations - Obtener anotaciones para una entidad
  • POST /tools/get_entity_children - Obtener entidades secundarias de una entidad contenedora
  • POST /tools/query_entities - Consultar entidades según varios criterios
  • POST /tools/query_table - Consultar una tabla de Synapse

Recursos

  • GET /resources - Lista de recursos disponibles
  • GET /resources/entity/{id} - Obtener la entidad por ID
  • GET /resources/entity/{id}/annotations - Obtener anotaciones de entidad
  • GET /resources/entity/{id}/children - Obtener hijos de la entidad
  • GET /resources/query/entities/{entity_type} - Consultar entidades por tipo
  • GET /resources/query/entities/parent/{parent_id} - Consultar entidades por ID principal
  • GET /resources/query/entities/name/{name} - Consultar entidades por nombre
  • GET /resources/query/table/{id}/{query} - Consulta una tabla con sintaxis similar a SQL

Ejemplos

Autenticación

Debes autenticarte con credenciales reales de Synapse para usar el servidor:

import requests # Authenticate with Synapse response = requests.post("http://127.0.0.1:9000/tools/authenticate", json={ "email": "your-synapse-email@example.com", "password": "your-synapse-password" }) result = response.json() print(result) # Alternatively, you can authenticate with an API key response = requests.post("http://127.0.0.1:9000/tools/authenticate", json={ "api_key": "your-synapse-api-key" })

Obtener una entidad

import requests # Get an entity by ID response = requests.get("http://127.0.0.1:9000/resources/entity/syn123456") # Replace with a real Synapse ID entity = response.json() print(entity)

Obtener anotaciones de entidades

import requests # Get annotations for an entity response = requests.get("http://127.0.0.1:9000/resources/entity/syn123456/annotations") # Replace with a real Synapse ID annotations = response.json() print(annotations)

Consulta de entidades

import requests # Query for files in a project response = requests.get("http://127.0.0.1:9000/resources/query/entities/parent/syn123456", params={ # Replace with a real Synapse ID "entity_type": "file" }) files = response.json() print(files)

Consultar una tabla

import requests # Query a table table_id = "syn123456" # Replace with a real Synapse table ID query = "SELECT * FROM syn123456 LIMIT 10" # Replace with a real Synapse table ID response = requests.get(f"http://127.0.0.1:9000/resources/query/table/{table_id}/{query}") table_data = response.json() print(table_data)

Obtener conjuntos de datos en formato Croissant

import requests import json # Get public datasets in Croissant format response = requests.get("http://127.0.0.1:9000/resources/croissant/datasets") croissant_data = response.json() # Save to file with open("croissant_metadata.json", "w") as f: json.dump(croissant_data, f, indent=2)

Licencia

Instituto Tecnológico de Massachusetts (MIT)

-
security - not tested
A
license - permissive license
-
quality - not tested

Un servidor de protocolo de contexto de modelo que expone entidades de Synapse (conjuntos de datos, proyectos, carpetas, archivos, tablas) con sus anotaciones, lo que permite el acceso programático a los recursos de datos de Synapse a través de una API RESTful.

  1. Overview
    1. Installation
      1. Installing from PyPI
    2. Usage
      1. Starting the Server
      2. Using the CLI
      3. Command-line Options
      4. Running Tests
      5. Testing the Server
    3. API Endpoints
      1. Server Information
      2. Tools
      3. Resources
    4. Examples
      1. Authentication
      2. Getting an Entity
      3. Getting Entity Annotations
      4. Querying Entities
      5. Querying a Table
      6. Getting Datasets in Croissant Format
    5. License
      ID: svgnoean1v