Complete daemon RPC with per-request context routing (bd-115)
- MCP server now uses daemon client by default with CLI fallback - Added BEADS_USE_DAEMON environment variable (default: enabled) - Created multi-repo integration test (all tests pass) - Updated .gitignore for daemon runtime files - Added SETUP_DAEMON.md with migration instructions - Closed bd-105 (investigation complete) and bd-114 (multi-server confusion) This enables single MCP server to handle multiple repos via daemon with per-request context routing. No more multiple MCP server configs! Amp-Thread-ID: https://ampcode.com/threads/T-c222692e-f6ef-4649-9726-db59470b82ef Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
"""MCP tools for beads issue tracker."""
|
||||
|
||||
import os
|
||||
from typing import Annotated
|
||||
|
||||
from .bd_client import BdClient, BdError
|
||||
from .bd_client import create_bd_client, BdClientBase, BdError
|
||||
from .models import (
|
||||
AddDependencyParams,
|
||||
BlockedIssue,
|
||||
@@ -22,7 +23,7 @@ from .models import (
|
||||
)
|
||||
|
||||
# Global client instance - initialized on first use
|
||||
_client: BdClient | None = None
|
||||
_client: BdClientBase | None = None
|
||||
_version_checked: bool = False
|
||||
|
||||
# Default constants
|
||||
@@ -30,20 +31,28 @@ DEFAULT_ISSUE_TYPE: IssueType = "task"
|
||||
DEFAULT_DEPENDENCY_TYPE: DependencyType = "blocks"
|
||||
|
||||
|
||||
async def _get_client() -> BdClient:
|
||||
async def _get_client() -> BdClientBase:
|
||||
"""Get a BdClient instance, creating it on first use.
|
||||
|
||||
Performs version check on first initialization.
|
||||
Uses daemon client if available, falls back to CLI client.
|
||||
|
||||
Returns:
|
||||
Configured BdClient instance (config loaded automatically)
|
||||
Configured BdClientBase instance (config loaded automatically)
|
||||
|
||||
Raises:
|
||||
BdError: If bd is not installed or version is incompatible
|
||||
"""
|
||||
global _client, _version_checked
|
||||
if _client is None:
|
||||
_client = BdClient()
|
||||
# Check if daemon should be used (default: yes)
|
||||
use_daemon = os.environ.get("BEADS_USE_DAEMON", "1") == "1"
|
||||
workspace_root = os.environ.get("BEADS_WORKING_DIR")
|
||||
|
||||
_client = create_bd_client(
|
||||
prefer_daemon=use_daemon,
|
||||
workspace_root=workspace_root
|
||||
)
|
||||
|
||||
# Check version once per server lifetime
|
||||
if not _version_checked:
|
||||
|
||||
Reference in New Issue
Block a user