/** * Crewly MCP Server Service * * Exposes Crewly capabilities as MCP (Model Context Protocol) tools so that * external AI tools — Claude Code, Cursor, Windsurf, etc. — can manage * Crewly teams via the standard MCP protocol. * * This is Crewly's unique differentiator: no competitor offers a * "team management backend" controllable via MCP. * * Supported tools: * - crewly_get_teams — List all teams and their members/status * - crewly_create_team — Create a new team with members * - crewly_assign_task — Give a task to a specific agent (creates a WorkItem via the running backend) * - crewly_get_status — Get agent/team status * - crewly_recall_memory — Search team memory/knowledge * - crewly_send_message — Send a message to an agent * * @module services/mcp-server */ /** * MCP Server configuration constants. */ export declare const MCP_SERVER_CONSTANTS: { /** Server identification sent during MCP handshake */ readonly SERVER_INFO: { readonly NAME: "crewly-mcp-server"; readonly VERSION: "1.0.0"; }; /** Tool name prefix for namespacing */ readonly TOOL_PREFIX: "crewly"; /** crewly_assign_task: WorkItem title / description caps (callers cap description at 500) */ readonly ASSIGN_TASK: { readonly TITLE_MAX_CHARS: 120; readonly DESCRIPTION_MAX_CHARS: 500; }; }; /** * Configuration for the Crewly MCP Server. */ export interface CrewlyMcpServerConfig { /** Path to the crewly home directory (default: ~/.crewly) */ crewlyHome?: string; /** HTTP client used to reach the local backend (tests inject one) */ fetchImpl?: typeof fetch; } /** * CrewlyMcpServer exposes Crewly team management capabilities as MCP tools. * * External AI tools can connect to this server via stdio transport and use * the provided tools to create teams, assign tasks, check status, search * memory, and send messages — all through the standard MCP protocol. * * @example * ```typescript * const mcpServer = new CrewlyMcpServer(); * await mcpServer.start(); // Starts on stdio * ``` * * @example Claude Code configuration (~/.claude/claude_desktop_config.json): * ```json * { * "mcpServers": { * "crewly": { * "command": "npx", * "args": ["crewly", "mcp-server"] * } * } * } * ``` */ export declare class CrewlyMcpServer { private server; private readonly storage; private readonly memory; private transport; private stdioTransportCtor; /** HTTP client for the local backend API (see {@link CrewlyMcpServerConfig.fetchImpl}) */ private readonly fetchImpl; private geminiCliHelper; private getGeminiCliHelper; /** * Creates a new CrewlyMcpServer instance. * * @param config - Optional server configuration */ constructor(config?: CrewlyMcpServerConfig); /** * Register MCP request handlers for tool listing and tool calling. */ private registerHandlers; /** * Build the Server + transport + handlers from already-loaded SDK modules. * Returns false if any expected SDK symbol is missing (so the caller can * decide whether to throw or silently fall back). Both `ensureInitialized` * (dynamic import) and `tryInitializeWithRequire` (CommonJS require) feed * their loaded modules through here. */ private installSdkModules; private ensureInitialized; private tryInitializeWithRequire; /** * Route a tool call to the appropriate handler. * * @param name - Tool name * @param args - Tool arguments * @returns Tool result with content blocks */ private handleToolCall; /** * Format a TeamMember for an MCP response. Three variants share the * same base (id/name/role/agentStatus/workingStatus); `includeRuntime` * adds `runtimeType` + `sessionName`, and `includeTickets` adds * `currentTickets`. Keeping all three paths in one place so that a * field added to the member shape only needs to be surfaced once. */ private formatMember; /** * Handle crewly_get_teams: list all teams and their members. * * @param args - Optional { teamId } to filter * @returns Formatted team list */ private handleGetTeams; /** * Handle crewly_create_team: create a new team with members. * * @param args - { name, description?, members: [{name, role, runtimeType?}] } * @returns Created team info */ private handleCreateTeam; /** * Handle crewly_assign_task: give a task to a specific agent as a real * WorkItem in the task pool. * * The MCP server runs in its own process, so it does not touch the pool * file itself — it asks the running Crewly backend * (`POST /api/task-pool/add`), which validates the target, stores the item * and dispatches it to the agent like any delegated work. Until 2026-09-28 * this only appended a made-up id to the member's `currentTickets`, which * nothing ever read. * * @param args - { teamId, memberId, task } * @returns The new WorkItem id, or an error when the backend refuses or is down */ private handleAssignTask; /** * Handle crewly_get_status: get status for teams/agents. * * @param args - Optional { teamId, memberId } filters * @returns Status information */ private handleGetStatus; /** * Handle crewly_recall_memory: search team memory/knowledge. * * @param args - { query, agentId?, projectPath?, scope? } * @returns Search results */ private handleRecallMemory; /** * Handle crewly_send_message: send a message to the orchestrator. * * @param args - { message, conversationId? } * @returns Confirmation with message ID */ private handleSendMessage; /** * Handle crewly_credential_list: return credential metadata (no values). */ private handleCredentialList; /** * Handle crewly_credential_add_api_key: store an API key. */ private handleCredentialAddApiKey; /** * Handle crewly_credential_oauth_import_gemini_cli: capture the current * gemini-cli-workspace extension login into an encrypted Crewly credential. */ private handleCredentialImportGeminiCli; /** * Handle crewly_credential_clear_gemini_cli_file: delete the extension's * cached token file so the next extension login captures a fresh account. */ private handleCredentialClearGeminiCliFile; /** * Handle crewly_credential_delete: remove a credential. */ private handleCredentialDelete; /** * Handle crewly_execute_skill: run a skill with optional credential bindings. */ private handleExecuteSkill; /** * Create a success result with JSON-serialized content. * * @param data - Data to serialize as the result * @returns ToolResult with text content */ private successResult; /** * Create an error result. * * @param message - Error message * @returns ToolResult with isError flag */ private errorResult; /** * Start the MCP server on stdio transport. * * This connects stdin/stdout for MCP protocol communication. * The process will stay alive until the client disconnects. */ start(): Promise; /** * Stop the MCP server and clean up resources. */ stop(): Promise; /** * Get the underlying MCP Server instance (for testing). * * @returns The Server instance */ getServer(): any; } //# sourceMappingURL=mcp-server.d.ts.map