deepsource-mcp-server
Version:
Model Context Protocol server for DeepSource
115 lines (114 loc) • 3.56 kB
TypeScript
/**
* @fileoverview MCP Server module for DeepSource integration
*
* This module provides a configurable MCP server that can be used
* to integrate DeepSource functionality with Model Context Protocol.
* It separates the server setup logic from the main entry point,
* allowing for better testability and reusability.
*
* @packageDocumentation
*/
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
import { ToolRegistry } from './tool-registry.js';
import { BaseHandlerDeps } from '../handlers/base/handler.interface.js';
/**
* Configuration options for the MCP server
*/
export interface MCPServerConfig {
/** Server name */
name?: string;
/** Server version */
version?: string;
/** Custom handler dependencies */
handlerDeps?: BaseHandlerDeps;
/** Whether to auto-register DeepSource tools */
autoRegisterTools?: boolean;
/** Custom transport (defaults to StdioServerTransport) */
transport?: StdioServerTransport;
/** Whether to start the server immediately */
autoStart?: boolean;
}
/**
* DeepSource MCP Server class
*
* This class encapsulates the MCP server setup and configuration,
* providing a clean API for creating and managing the server.
*/
export declare class DeepSourceMCPServer {
private mcpServer;
private toolRegistry;
private transport?;
private config;
private isConnected;
constructor(config?: MCPServerConfig);
/**
* Registers the default DeepSource tools
*/
private registerDefaultTools;
/**
* Gets the MCP server instance
*/
getMcpServer(): McpServer;
/**
* Gets the tool registry
*/
getToolRegistry(): ToolRegistry;
/**
* Connects the server to the transport
*
* @param transport - Optional transport to use (overrides constructor transport)
*/
connect(transport?: StdioServerTransport): Promise<void>;
/**
* Starts the server (convenience method that creates transport and connects)
*/
start(): Promise<void>;
/**
* Checks if the server is connected
*/
isServerConnected(): boolean;
/**
* Updates handler dependencies
*
* @param deps - New handler dependencies
*/
updateHandlerDeps(deps: BaseHandlerDeps): void;
/**
* Gets registered tool names
*/
getRegisteredTools(): string[];
/**
* Discovers and loads tools from filesystem (requires FEATURE_TOOL_DISCOVERY)
*
* @param options - Discovery options
* @returns Array of discovered tool names
*/
discoverTools(options?: Record<string, unknown>): Promise<string[]>;
/**
* Gets enhanced tool information including metadata
*/
getToolsInfo(): Array<{
name: string;
description: string;
category?: string;
version?: string;
tags?: string[];
enabled?: boolean;
discovered?: boolean;
}>;
/**
* Creates and optionally starts a DeepSource MCP server
*
* @param config - Server configuration
* @returns The created server instance
*/
static create(config?: MCPServerConfig): Promise<DeepSourceMCPServer>;
}
/**
* Convenience function to create a server with default configuration
*
* @param autoStart - Whether to start the server immediately
* @returns The created server instance
*/
export declare function createDeepSourceMCPServer(autoStart?: boolean): Promise<DeepSourceMCPServer>;