This document provides detailed API reference for the MCP Config Watcher's core classes and methods.
The parser class that extracts information from the MCP settings file.
import { MCPSettingsParser } from 'mcp-config-watcher';
const parser = new MCPSettingsParser(config);
const data = await parser.parse('/path/to/settings.json');new MCPSettingsParser(config)config(Object): Configuration object
Parses the MCP settings file and extracts server information.
filePath(string): Path to the MCP settings file- Returns:
Promise<Object>- Parsed data
Gets the description for a specific tool.
toolName(string): Name of the tool- Returns:
string- Tool description
Gets tools for a specific server from the mapping or config.
serverId(string): Server IDserverToolsMap(Object): Map of server IDs to tool namesserverConfig(Object): Server configuration from settings- Returns:
Array<string>- Array of tool names
Builds a mapping of server IDs to their tools.
- Returns:
Object- Map of server IDs to arrays of tool names
Extracts server and tool information from MCP settings.
mcpSettings(Object): Parsed MCP settings object- Returns:
Object- Extracted server and tool information
Gets a tool description, using AI if no static description is available.
toolName(string): Name of the toolserverId(string): Server ID- Returns:
Promise<string>- Tool description
Discovers tools for a server using static mapping, auto-approve list, and AI.
serverId(string): Server IDserverConfig(Object): Server configuration- Returns:
Promise<Array<string>>- Discovered tools
Extracts server info with AI-enhanced tool discovery.
mcpSettings(Object): Parsed MCP settings object- Returns:
Promise<Object>- Extracted server and tool information
The generator class that creates and updates the markdown documentation.
import { MDGenerator } from 'mcp-config-watcher';
const generator = new MDGenerator(config, parser);
await generator.generateMarkdown(data);new MDGenerator(config, parser)config(Object): Configuration objectparser(MCPSettingsParser): Parser instance
Generates the markdown documentation.
data(Object): Parsed MCP settings data- Returns:
Promise<boolean>- Success status
Safely updates the markdown file preserving user content.
filePath(string): Path to the markdown filedata(Object): Parsed MCP settings datasettings(Object): Raw MCP settings- Returns:
Promise<void>
Parses existing markdown content into sections.
content(string): Existing markdown content- Returns:
Object- Parsed sections
Generates server sections for the markdown file.
data(Object): Parsed MCP settings datasettings(Object): Raw MCP settings- Returns:
Object- Server sections
Merges existing content with new server sections.
existingSections(Object): Existing content sectionsnewServerSections(Object): New server sections- Returns:
string- Merged content
Builds markdown content for a new file.
data(Object): Parsed MCP settings datasettings(Object): Raw MCP settings- Returns:
string- Markdown content
The watcher class that monitors the MCP settings file for changes.
import { MCPWatcher } from 'mcp-config-watcher';
const watcher = new MCPWatcher(config);
await watcher.start();new MCPWatcher(config)config(Object): Configuration object
Starts watching the MCP settings file.
- Returns:
Promise<boolean>- Success status
Stops watching the MCP settings file.
- Returns:
Promise<boolean>- Success status
Checks if the watcher is running.
- Returns:
boolean- Running status
Manually updates the documentation.
- Returns:
Promise<boolean>- Success status
The service class that coordinates the components and manages the lifecycle.
import { MCPService } from 'mcp-config-watcher';
const service = new MCPService(config);
await service.start();new MCPService(config)config(Object): Configuration object
Starts the service.
- Returns:
Promise<boolean>- Success status
Stops the service.
- Returns:
Promise<boolean>- Success status
Checks if the service is running.
- Returns:
boolean- Running status
Processes a change to the MCP settings file.
filePath(string): Path to the changed file- Returns:
Promise<boolean>- Success status
The AI helper class that enhances tool discovery and descriptions.
import { AIHelper } from 'mcp-config-watcher';
const aiHelper = new AIHelper(config);
const tools = await aiHelper.predictToolsForServer('github.com/example/server');new AIHelper(config)config(Object): Configuration object
Predicts tools for a server based on its ID.
serverId(string): The server ID- Returns:
Promise<Array<string>>- Array of predicted tools
Generates a description for a tool.
toolName(string): The tool nameserverId(string): The server ID for context- Returns:
Promise<string>- Generated description
The command line interface for the MCP Config Watcher.
mcp-watcher <command> [options]start: Start the watcherstop: Stop the watcherstatus: Check the status of the watcherupdate: Update the documentationweb: Start the web dashboardtray: Start the system tray application
--config, -c: Path to the configuration file--verbose, -v: Enable verbose logging--help, -h: Show help
The web API for the MCP Config Watcher dashboard.
Get the status of the watcher.
- Response:
{ "running": true, "uptime": 3600, "lastUpdate": "2025-03-15T16:58:42.000Z" }
Start the watcher.
- Response:
{ "success": true, "message": "Watcher started" }
Stop the watcher.
- Response:
{ "success": true, "message": "Watcher stopped" }
Update the documentation.
- Response:
{ "success": true, "message": "Documentation updated" }
Get the logs of the watcher.
- Response:
{ "logs": [ { "timestamp": "2025-03-15T16:58:42.000Z", "level": "info", "message": "Watcher started" } ] }
Get the configuration of the watcher.
- Response:
{ "paths": { "settings": "/path/to/settings.json", "markdown": "/path/to/output.md" }, "watcher": { "enabled": true, "pollInterval": 1000 } }
Update the configuration of the watcher.
- Request:
{ "paths": { "settings": "/path/to/settings.json", "markdown": "/path/to/output.md" }, "watcher": { "enabled": true, "pollInterval": 1000 } } - Response:
{ "success": true, "message": "Configuration updated" }
The schema for the configuration file.
# Schema for config.yml
type: object
properties:
paths:
type: object
properties:
settings:
type: string
description: Path to the MCP settings file
markdown:
type: string
description: Path to the output markdown file
required:
- settings
- markdown
watcher:
type: object
properties:
enabled:
type: boolean
description: Enable or disable file watching
pollInterval:
type: number
description: Poll interval in milliseconds
required:
- enabled
ai:
type: object
properties:
enabled:
type: boolean
description: Enable or disable AI-powered tool discovery
openai:
type: object
properties:
apiKey:
type: string
description: OpenAI API key
cache:
type: object
properties:
enabled:
type: boolean
description: Enable or disable caching
maxAge:
type: number
description: Cache expiration in milliseconds
fallback:
type: object
properties:
enabled:
type: boolean
description: Generate fallback tool names if none are found
required:
- pathsThe events emitted by the MCP Config Watcher.
start: Emitted when the service startsstop: Emitted when the service stopsfileChange: Emitted when the settings file changesupdateStart: Emitted when documentation update startsupdateEnd: Emitted when documentation update completeserror: Emitted when an error occurs
start: Emitted when the watcher startsstop: Emitted when the watcher stopsfileChange: Emitted when the watched file changeserror: Emitted when an error occurs
The MCP Config Watcher throws the following errors:
ConfigError: Configuration-related errorsFileError: File-related errorsParserError: Parsing-related errorsGeneratorError: Markdown generation errorsWatcherError: Watcher-related errorsServiceError: Service-related errorsAIError: AI-related errors
Example:
import { ConfigError } from 'mcp-config-watcher';
try {
// Code that might throw an error
} catch (error) {
if (error instanceof ConfigError) {
console.error('Configuration error:', error.message);
} else {
console.error('Unknown error:', error);
}
}The MCP Config Watcher uses the following environment variables:
MCP_CONFIG_PATH: Path to the configuration fileMCP_SETTINGS_PATH: Path to the MCP settings fileMCP_MARKDOWN_PATH: Path to the output markdown fileOPENAI_API_KEY: OpenAI API key for AI-powered tool discovery
Example:
export MCP_CONFIG_PATH=/path/to/config.yml
export OPENAI_API_KEY=your-api-key
mcp-watcher start