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.

Synapse MCP サーバー

Synapse エンティティ (データセット、プロジェクト、フォルダー、ファイル、テーブル) とその注釈を公開するモデル コンテキスト プロトコル (MCP) サーバー。

概要

このサーバーは、モデルコンテキストプロトコル(MCP)を介してSynapseエンティティとそのアノテーションにアクセスするためのRESTful APIを提供します。これにより、以下のことが可能になります。

  • Synapseで認証する
  • IDでエンティティを取得する
  • エンティティの注釈を取得する
  • エンティティの子を取得する
  • さまざまな基準に基づいてエンティティをクエリする
  • Synapseテーブルのクエリ

インストール

# 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 .

PyPIからのインストール

# Install from PyPI pip install synapse-mcp

使用法

サーバーの起動

python server.py

これにより、デフォルトのポート (9000) で MCP サーバーが起動します。

CLIの使用

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

コマンドラインオプション

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

テストの実行

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

サーバーのテスト

python examples/client_example.py

APIエンドポイント

サーバー情報

  • GET /info - サーバー情報を取得する

ツール

  • GET /tools - 利用可能なツールの一覧を取得する
  • POST /tools/authenticate - Synapseで認証する
  • POST /tools/get_entity - IDでエンティティを取得する
  • POST /tools/get_entity_annotations - エンティティの注釈を取得する
  • POST /tools/get_entity_children - コンテナエンティティの子エンティティを取得します
  • POST /tools/query_entities - さまざまな基準に基づいてエンティティをクエリする
  • POST /tools/query_table - Synapse テーブルをクエリする

リソース

  • GET /resources - 利用可能なリソースを一覧表示する
  • GET /resources/entity/{id} - IDでエンティティを取得する
  • GET /resources/entity/{id}/annotations - エンティティのアノテーションを取得する
  • GET /resources/entity/{id}/children - エンティティの子を取得する
  • GET /resources/query/entities/{entity_type} - タイプ別にエンティティをクエリする
  • GET /resources/query/entities/parent/{parent_id} - 親IDでエンティティをクエリする
  • GET /resources/query/entities/name/{name} - 名前でエンティティをクエリする
  • GET /resources/query/table/{id}/{query} - SQLのような構文でテーブルをクエリする

認証

サーバーを使用するには、実際の Synapse 資格情報で認証する必要があります。

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" })

エンティティの取得

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)

エンティティアノテーションの取得

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)

エンティティのクエリ

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)

テーブルのクエリ

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)

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)

ライセンス

マサチューセッツ工科大学

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

Synapse エンティティ (データセット、プロジェクト、フォルダー、ファイル、テーブル) を注釈とともに公開し、RESTful API を介して Synapse データ リソースへのプログラムによるアクセスを可能にするモデル コンテキスト プロトコル サーバー。

  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