lab-backend-template
A template for building MCP backends for lab equipment with an embedded Echo example for immediate testing and development.
README
lab-backend-template
lab-executor-mcp 用の機器バックエンドを作るための、実行可能なテンプレートです。lab-<protocol>-mcp を始める際の出発点として使います。空の TODO 集ではなく、clone直後からテストできる Echo example を同梱しています。
Echo example
- resource:
ECHO::<name>(大文字小文字を区別し、不正形式は拒否) - query:
GET <key> - write:
SET <key> <value> EchoBackend: resourceごとに独立したメモリ状態を持つ、動作する最小実装MockEchoBackend: BEF適合テスト用の厳密な*IDN?/CONFprobe を追加
python -m pip install -e ".[dev]"
pytest -q
lab-backend serve --resource ECHO::demo --dry-run
実通信プロトコルへ移植するときは、入力検証を残したまま backend.py の状態アクセス部分をtransport呼び出しへ置き換えます。詳細は USING_THIS_TEMPLATE.md を参照してください。
3つの利用モード
A. MCP server
lab-backend serve --resource ECHO::device1
CLIは凍結された公開API compose_server と run_mcp_with_control だけでserverを構成します。
B. Python library
from lab_backend_template import EchoBackend
backend = EchoBackend(resources=["ECHO::device1"])
C. lab-executor backend discovery
インストール時に entry point lab_executor.backends: echo が登録されます。lab-executor serve --backends echo または _system.yaml の backends: から選択できます。
安全設計(置換後も必須)
- 書き込み可能な対象は機器定義のcommandとして明示し、raw write APIを追加しないでください。
- 未知resource、未知opcode、不正な引数、未初期化keyは推測せず fail-closed で拒否します。
- readのretryとwriteのretryを分離してください。writeの自動retryは二重書き込みや二重動作を起こし得るため、既定で行わないでください。
- 各機器定義には安全側へ戻す
safe_shutdownを必ず定義してください。 - 実機未検証の定義は
support_level: experimentalとします。verifiedは対象実機で確認済みの場合だけ使用してください。 - このEcho実装は構造のexampleであり、物理装置の安全性を保証しません。実装時は装置固有の範囲、interlock、timeout、shutdownを追加してください。
開発と公開
CIはPython 3.11、Ruff、BEF適合、latest release統合、lab-executor main互換smoke、buildを検証します。タグはPyPI、手動workflowは既定でTestPyPIへTrusted Publishingで公開します。テンプレート自体は公開パッケージではないため、複製後に名前とmetadataを変更するまでtagを作らないでください。
ライセンス
MIT
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.