chore: set up pre-commit framework with general hooks
Add .pre-commit-config.yaml with pre-commit-hooks v5.0.0 (trailing whitespace, end-of-file fixer, yaml/json checks, large file guard, merge conflict detection). Add minimal pyproject.toml. Auto-fix trailing whitespace and missing end-of-file newlines across the codebase. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -36,7 +36,7 @@ export type Config = z.infer<typeof ConfigSchema>;
|
||||
|
||||
/**
|
||||
* Load configuration from file
|
||||
*
|
||||
*
|
||||
* @param configPath Path to the configuration file (optional)
|
||||
* @returns Loaded and validated configuration
|
||||
*/
|
||||
@@ -44,22 +44,22 @@ export async function loadConfig(configPath?: string): Promise<Config> {
|
||||
try {
|
||||
// Determine which config file to load
|
||||
const filePath = configPath || DEFAULT_CONFIG_PATH;
|
||||
|
||||
|
||||
// Check if file exists
|
||||
if (!existsSync(filePath)) {
|
||||
logger.warn(`Configuration file not found: ${filePath}, using defaults`);
|
||||
return ConfigSchema.parse({});
|
||||
}
|
||||
|
||||
|
||||
// Read and parse configuration
|
||||
const configData = await readFile(filePath, 'utf-8');
|
||||
const config = JSON.parse(configData);
|
||||
|
||||
|
||||
// Validate configuration
|
||||
return ConfigSchema.parse(config);
|
||||
} catch (error) {
|
||||
logger.error(`Error loading configuration: ${error}`);
|
||||
|
||||
|
||||
// Return default configuration
|
||||
return ConfigSchema.parse({});
|
||||
}
|
||||
|
||||
24
src/index.ts
24
src/index.ts
@@ -21,27 +21,27 @@ async function main() {
|
||||
// Parse command line arguments
|
||||
const args = process.argv.slice(2);
|
||||
const options = parseCommandLineArgs(args);
|
||||
|
||||
|
||||
// Load configuration
|
||||
const config = await loadConfig(options.configPath);
|
||||
|
||||
|
||||
// Path to the Python script that interfaces with KiCAD
|
||||
const kicadScriptPath = join(dirname(__dirname), 'python', 'kicad_interface.py');
|
||||
|
||||
|
||||
// Create the server
|
||||
const server = new KiCADMcpServer(
|
||||
kicadScriptPath,
|
||||
config.logLevel
|
||||
);
|
||||
|
||||
|
||||
// Start the server
|
||||
await server.start();
|
||||
|
||||
|
||||
// Setup graceful shutdown
|
||||
setupGracefulShutdown(server);
|
||||
|
||||
|
||||
logger.info('KiCAD MCP server started with STDIO transport');
|
||||
|
||||
|
||||
} catch (error) {
|
||||
logger.error(`Failed to start KiCAD MCP server: ${error}`);
|
||||
process.exit(1);
|
||||
@@ -53,14 +53,14 @@ async function main() {
|
||||
*/
|
||||
function parseCommandLineArgs(args: string[]) {
|
||||
let configPath = undefined;
|
||||
|
||||
|
||||
for (let i = 0; i < args.length; i++) {
|
||||
if (args[i] === '--config' && i + 1 < args.length) {
|
||||
configPath = args[i + 1];
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return { configPath };
|
||||
}
|
||||
|
||||
@@ -73,18 +73,18 @@ function setupGracefulShutdown(server: KiCADMcpServer) {
|
||||
logger.info('Received SIGINT signal. Shutting down...');
|
||||
await shutdownServer(server);
|
||||
});
|
||||
|
||||
|
||||
process.on('SIGTERM', async () => {
|
||||
logger.info('Received SIGTERM signal. Shutting down...');
|
||||
await shutdownServer(server);
|
||||
});
|
||||
|
||||
|
||||
// Handle uncaught exceptions
|
||||
process.on('uncaughtException', async (error) => {
|
||||
logger.error(`Uncaught exception: ${error}`);
|
||||
await shutdownServer(server);
|
||||
});
|
||||
|
||||
|
||||
// Handle unhandled promise rejections
|
||||
process.on('unhandledRejection', async (reason) => {
|
||||
logger.error(`Unhandled promise rejection: ${reason}`);
|
||||
|
||||
@@ -26,12 +26,12 @@ class KiCADServer {
|
||||
// Set absolute path to the Python KiCAD interface script
|
||||
// Using a hardcoded path to avoid cwd() issues when running from Cline
|
||||
this.kicadScriptPath = 'c:/repo/KiCAD-MCP/python/kicad_interface.py';
|
||||
|
||||
|
||||
// Check if script exists
|
||||
if (!existsSync(this.kicadScriptPath)) {
|
||||
throw new Error(`KiCAD interface script not found: ${this.kicadScriptPath}`);
|
||||
}
|
||||
|
||||
|
||||
// Initialize the server
|
||||
this.server = new Server(
|
||||
{
|
||||
@@ -46,7 +46,7 @@ class KiCADServer {
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
// Initialize handler with direct pass-through to Python KiCAD interface
|
||||
// We don't register TypeScript tools since we'll handle everything in Python
|
||||
|
||||
@@ -96,7 +96,7 @@ class KiCADServer {
|
||||
properties: {}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
// Board tools
|
||||
{
|
||||
name: 'set_board_size',
|
||||
@@ -129,7 +129,7 @@ class KiCADServer {
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
// Component tools
|
||||
{
|
||||
name: 'place_component',
|
||||
@@ -147,7 +147,7 @@ class KiCADServer {
|
||||
required: ['componentId', 'position']
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
// Routing tools
|
||||
{
|
||||
name: 'add_net',
|
||||
@@ -176,7 +176,7 @@ class KiCADServer {
|
||||
required: ['start', 'end']
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
// Schematic tools
|
||||
{
|
||||
name: 'create_schematic',
|
||||
@@ -209,8 +209,8 @@ class KiCADServer {
|
||||
type: 'object',
|
||||
properties: {
|
||||
schematicPath: { type: 'string', description: 'Path to the schematic file' },
|
||||
component: {
|
||||
type: 'object',
|
||||
component: {
|
||||
type: 'object',
|
||||
description: 'Component definition',
|
||||
properties: {
|
||||
type: { type: 'string', description: 'Component type (e.g., R, C, LED)' },
|
||||
@@ -235,15 +235,15 @@ class KiCADServer {
|
||||
type: 'object',
|
||||
properties: {
|
||||
schematicPath: { type: 'string', description: 'Path to the schematic file' },
|
||||
startPoint: {
|
||||
type: 'array',
|
||||
startPoint: {
|
||||
type: 'array',
|
||||
description: 'Starting point coordinates [x, y]',
|
||||
items: { type: 'number' },
|
||||
minItems: 2,
|
||||
maxItems: 2
|
||||
},
|
||||
endPoint: {
|
||||
type: 'array',
|
||||
endPoint: {
|
||||
type: 'array',
|
||||
description: 'Ending point coordinates [x, y]',
|
||||
items: { type: 'number' },
|
||||
minItems: 2,
|
||||
@@ -259,8 +259,8 @@ class KiCADServer {
|
||||
inputSchema: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
searchPaths: {
|
||||
type: 'array',
|
||||
searchPaths: {
|
||||
type: 'array',
|
||||
description: 'Optional search paths for libraries',
|
||||
items: { type: 'string' }
|
||||
}
|
||||
@@ -286,7 +286,7 @@ class KiCADServer {
|
||||
this.server.setRequestHandler(CallToolRequestSchema, async (request: any) => {
|
||||
const toolName = request.params.name;
|
||||
const args = request.params.arguments || {};
|
||||
|
||||
|
||||
// Pass all commands directly to KiCAD Python interface
|
||||
try {
|
||||
return await this.callKicadScript(toolName, args);
|
||||
@@ -300,11 +300,11 @@ class KiCADServer {
|
||||
async start() {
|
||||
try {
|
||||
console.error('Starting KiCAD MCP server...');
|
||||
|
||||
|
||||
// Start the Python process for KiCAD scripting
|
||||
console.error(`Starting Python process with script: ${this.kicadScriptPath}`);
|
||||
const pythonExe = 'C:\\Program Files\\KiCad\\9.0\\bin\\python.exe';
|
||||
|
||||
|
||||
console.error(`Using Python executable: ${pythonExe}`);
|
||||
this.pythonProcess = spawn(pythonExe, [this.kicadScriptPath], {
|
||||
stdio: ['pipe', 'pipe', 'pipe'],
|
||||
@@ -313,30 +313,30 @@ class KiCADServer {
|
||||
PYTHONPATH: 'C:/Program Files/KiCad/9.0/lib/python3/dist-packages'
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Listen for process exit
|
||||
this.pythonProcess.on('exit', (code, signal) => {
|
||||
console.error(`Python process exited with code ${code} and signal ${signal}`);
|
||||
this.pythonProcess = null;
|
||||
});
|
||||
|
||||
|
||||
// Listen for process errors
|
||||
this.pythonProcess.on('error', (err) => {
|
||||
console.error(`Python process error: ${err.message}`);
|
||||
});
|
||||
|
||||
|
||||
// Set up error logging for stderr
|
||||
if (this.pythonProcess.stderr) {
|
||||
this.pythonProcess.stderr.on('data', (data: Buffer) => {
|
||||
console.error(`Python stderr: ${data.toString()}`);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// Connect to transport
|
||||
const transport = new StdioServerTransport();
|
||||
await this.server.connect(transport);
|
||||
console.error('KiCAD MCP server running');
|
||||
|
||||
|
||||
// Keep the process running
|
||||
process.on('SIGINT', () => {
|
||||
if (this.pythonProcess) {
|
||||
@@ -345,7 +345,7 @@ class KiCADServer {
|
||||
this.server.close().catch(console.error);
|
||||
process.exit(0);
|
||||
});
|
||||
|
||||
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof Error) {
|
||||
console.error('Failed to start MCP server:', error.message);
|
||||
@@ -364,73 +364,73 @@ class KiCADServer {
|
||||
reject(new Error("Python process for KiCAD scripting is not running"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Add request to queue
|
||||
this.requestQueue.push({
|
||||
request: { command, params },
|
||||
resolve,
|
||||
reject
|
||||
});
|
||||
|
||||
|
||||
// Process the queue if not already processing
|
||||
if (!this.processingRequest) {
|
||||
this.processNextRequest();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private processNextRequest(): void {
|
||||
// If no more requests or already processing, return
|
||||
if (this.requestQueue.length === 0 || this.processingRequest) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Set processing flag
|
||||
this.processingRequest = true;
|
||||
|
||||
|
||||
// Get the next request
|
||||
const { request, resolve, reject } = this.requestQueue.shift()!;
|
||||
|
||||
|
||||
try {
|
||||
console.error(`Processing KiCAD command: ${request.command}`);
|
||||
|
||||
|
||||
// Format the command and parameters as JSON
|
||||
const requestStr = JSON.stringify(request);
|
||||
|
||||
|
||||
// Set up response handling
|
||||
let responseData = '';
|
||||
|
||||
|
||||
// Clear any previous listeners
|
||||
if (this.pythonProcess?.stdout) {
|
||||
this.pythonProcess.stdout.removeAllListeners('data');
|
||||
}
|
||||
|
||||
|
||||
// Set up new listeners
|
||||
if (this.pythonProcess?.stdout) {
|
||||
this.pythonProcess.stdout.on('data', (data: Buffer) => {
|
||||
const chunk = data.toString();
|
||||
console.error(`Received data chunk: ${chunk.length} bytes`);
|
||||
responseData += chunk;
|
||||
|
||||
|
||||
// Check if we have a complete response
|
||||
try {
|
||||
// Try to parse the response as JSON
|
||||
const result = JSON.parse(responseData);
|
||||
|
||||
|
||||
// If we get here, we have a valid JSON response
|
||||
console.error(`Completed KiCAD command: ${request.command} with result: ${JSON.stringify(result)}`);
|
||||
|
||||
|
||||
// Reset processing flag
|
||||
this.processingRequest = false;
|
||||
|
||||
|
||||
// Process next request if any
|
||||
setTimeout(() => this.processNextRequest(), 0);
|
||||
|
||||
|
||||
// Clear listeners
|
||||
if (this.pythonProcess?.stdout) {
|
||||
this.pythonProcess.stdout.removeAllListeners('data');
|
||||
}
|
||||
|
||||
|
||||
// Resolve with the expected MCP tool response format
|
||||
if (result.success) {
|
||||
resolve({
|
||||
@@ -457,38 +457,38 @@ class KiCADServer {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// Set a timeout
|
||||
const timeout = setTimeout(() => {
|
||||
console.error(`Command timeout: ${request.command}`);
|
||||
|
||||
|
||||
// Clear listeners
|
||||
if (this.pythonProcess?.stdout) {
|
||||
this.pythonProcess.stdout.removeAllListeners('data');
|
||||
}
|
||||
|
||||
|
||||
// Reset processing flag
|
||||
this.processingRequest = false;
|
||||
|
||||
|
||||
// Process next request
|
||||
setTimeout(() => this.processNextRequest(), 0);
|
||||
|
||||
|
||||
// Reject the promise
|
||||
reject(new Error(`Command timeout: ${request.command}`));
|
||||
}, 30000); // 30 seconds timeout
|
||||
|
||||
|
||||
// Write the request to the Python process
|
||||
console.error(`Sending request: ${requestStr}`);
|
||||
this.pythonProcess?.stdin?.write(requestStr + '\n');
|
||||
} catch (error) {
|
||||
console.error(`Error processing request: ${error}`);
|
||||
|
||||
|
||||
// Reset processing flag
|
||||
this.processingRequest = false;
|
||||
|
||||
|
||||
// Process next request
|
||||
setTimeout(() => this.processNextRequest(), 0);
|
||||
|
||||
|
||||
// Reject the promise
|
||||
reject(error);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ const DEFAULT_LOG_DIR = join(os.homedir(), '.kicad-mcp', 'logs');
|
||||
class Logger {
|
||||
private logLevel: LogLevel = 'info';
|
||||
private logDir: string = DEFAULT_LOG_DIR;
|
||||
|
||||
|
||||
/**
|
||||
* Set the log level
|
||||
* @param level Log level to set
|
||||
@@ -26,20 +26,20 @@ class Logger {
|
||||
setLogLevel(level: LogLevel): void {
|
||||
this.logLevel = level;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the log directory
|
||||
* @param dir Directory to store log files
|
||||
*/
|
||||
setLogDir(dir: string): void {
|
||||
this.logDir = dir;
|
||||
|
||||
|
||||
// Ensure log directory exists
|
||||
if (!existsSync(this.logDir)) {
|
||||
mkdirSync(this.logDir, { recursive: true });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Log an error message
|
||||
* @param message Message to log
|
||||
@@ -47,7 +47,7 @@ class Logger {
|
||||
error(message: string): void {
|
||||
this.log('error', message);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Log a warning message
|
||||
* @param message Message to log
|
||||
@@ -57,7 +57,7 @@ class Logger {
|
||||
this.log('warn', message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Log an info message
|
||||
* @param message Message to log
|
||||
@@ -67,7 +67,7 @@ class Logger {
|
||||
this.log('info', message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Log a debug message
|
||||
* @param message Message to log
|
||||
@@ -77,7 +77,7 @@ class Logger {
|
||||
this.log('debug', message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Log a message with the specified level
|
||||
* @param level Log level
|
||||
@@ -93,14 +93,14 @@ class Logger {
|
||||
// Log to console.error (stderr) only - stdout is reserved for MCP protocol
|
||||
// All log levels go to stderr to avoid corrupting STDIO MCP transport
|
||||
console.error(formattedMessage);
|
||||
|
||||
|
||||
// Log to file
|
||||
try {
|
||||
// Ensure log directory exists
|
||||
if (!existsSync(this.logDir)) {
|
||||
mkdirSync(this.logDir, { recursive: true });
|
||||
}
|
||||
|
||||
|
||||
const logFile = join(this.logDir, `kicad-mcp-${new Date().toISOString().split('T')[0]}.log`);
|
||||
appendFileSync(logFile, formattedMessage + '\n');
|
||||
} catch (error) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Component prompts for KiCAD MCP server
|
||||
*
|
||||
*
|
||||
* These prompts guide the LLM in providing assistance with component-related tasks
|
||||
* in KiCAD PCB design.
|
||||
*/
|
||||
@@ -11,7 +11,7 @@ import { logger } from '../logger.js';
|
||||
|
||||
/**
|
||||
* Register component prompts with the MCP server
|
||||
*
|
||||
*
|
||||
* @param server MCP server instance
|
||||
*/
|
||||
export function registerComponentPrompts(server: McpServer): void {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Design prompts for KiCAD MCP server
|
||||
*
|
||||
*
|
||||
* These prompts guide the LLM in providing assistance with general PCB design tasks
|
||||
* in KiCAD.
|
||||
*/
|
||||
@@ -11,7 +11,7 @@ import { logger } from '../logger.js';
|
||||
|
||||
/**
|
||||
* Register design prompts with the MCP server
|
||||
*
|
||||
*
|
||||
* @param server MCP server instance
|
||||
*/
|
||||
export function registerDesignPrompts(server: McpServer): void {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Routing prompts for KiCAD MCP server
|
||||
*
|
||||
*
|
||||
* These prompts guide the LLM in providing assistance with routing-related tasks
|
||||
* in KiCAD PCB design.
|
||||
*/
|
||||
@@ -11,7 +11,7 @@ import { logger } from '../logger.js';
|
||||
|
||||
/**
|
||||
* Register routing prompts with the MCP server
|
||||
*
|
||||
*
|
||||
* @param server MCP server instance
|
||||
*/
|
||||
export function registerRoutingPrompts(server: McpServer): void {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Board resources for KiCAD MCP server
|
||||
*
|
||||
*
|
||||
* These resources provide information about the PCB board
|
||||
* to the LLM, enabling better context-aware assistance.
|
||||
*/
|
||||
@@ -15,7 +15,7 @@ type CommandFunction = (command: string, params: Record<string, unknown>) => Pro
|
||||
|
||||
/**
|
||||
* Register board resources with the MCP server
|
||||
*
|
||||
*
|
||||
* @param server MCP server instance
|
||||
* @param callKicadScript Function to call KiCAD script commands
|
||||
*/
|
||||
@@ -31,7 +31,7 @@ export function registerBoardResources(server: McpServer, callKicadScript: Comma
|
||||
async (uri) => {
|
||||
logger.debug('Retrieving board information');
|
||||
const result = await callKicadScript("get_board_info", {});
|
||||
|
||||
|
||||
if (!result.success) {
|
||||
logger.error(`Failed to retrieve board information: ${result.errorDetails}`);
|
||||
return {
|
||||
@@ -45,7 +45,7 @@ export function registerBoardResources(server: McpServer, callKicadScript: Comma
|
||||
}]
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
logger.debug('Successfully retrieved board information');
|
||||
return {
|
||||
contents: [{
|
||||
@@ -66,7 +66,7 @@ export function registerBoardResources(server: McpServer, callKicadScript: Comma
|
||||
async (uri) => {
|
||||
logger.debug('Retrieving layer list');
|
||||
const result = await callKicadScript("get_layer_list", {});
|
||||
|
||||
|
||||
if (!result.success) {
|
||||
logger.error(`Failed to retrieve layer list: ${result.errorDetails}`);
|
||||
return {
|
||||
@@ -80,7 +80,7 @@ export function registerBoardResources(server: McpServer, callKicadScript: Comma
|
||||
}]
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
logger.debug(`Successfully retrieved ${result.layers?.length || 0} layers`);
|
||||
return {
|
||||
contents: [{
|
||||
@@ -107,10 +107,10 @@ export function registerBoardResources(server: McpServer, callKicadScript: Comma
|
||||
}),
|
||||
async (uri, params) => {
|
||||
const unit = params.unit || 'mm';
|
||||
|
||||
|
||||
logger.debug(`Retrieving board extents in ${unit}`);
|
||||
const result = await callKicadScript("get_board_extents", { unit });
|
||||
|
||||
|
||||
if (!result.success) {
|
||||
logger.error(`Failed to retrieve board extents: ${result.errorDetails}`);
|
||||
return {
|
||||
@@ -124,7 +124,7 @@ export function registerBoardResources(server: McpServer, callKicadScript: Comma
|
||||
}]
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
logger.debug('Successfully retrieved board extents');
|
||||
return {
|
||||
contents: [{
|
||||
@@ -156,7 +156,7 @@ export function registerBoardResources(server: McpServer, callKicadScript: Comma
|
||||
const height = params.height ? parseInt(params.height as string) : undefined;
|
||||
// Handle layers parameter - could be string or array
|
||||
const layers = typeof params.layers === 'string' ? params.layers.split(',') : params.layers;
|
||||
|
||||
|
||||
logger.debug('Retrieving 2D board view');
|
||||
const result = await callKicadScript("get_board_2d_view", {
|
||||
layers,
|
||||
@@ -164,7 +164,7 @@ export function registerBoardResources(server: McpServer, callKicadScript: Comma
|
||||
height,
|
||||
format
|
||||
});
|
||||
|
||||
|
||||
if (!result.success) {
|
||||
logger.error(`Failed to retrieve 2D board view: ${result.errorDetails}`);
|
||||
return {
|
||||
@@ -178,9 +178,9 @@ export function registerBoardResources(server: McpServer, callKicadScript: Comma
|
||||
}]
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
logger.debug('Successfully retrieved 2D board view');
|
||||
|
||||
|
||||
if (format === 'svg') {
|
||||
return {
|
||||
contents: [{
|
||||
@@ -219,14 +219,14 @@ export function registerBoardResources(server: McpServer, callKicadScript: Comma
|
||||
const angle = params.angle || 'isometric';
|
||||
const width = params.width ? parseInt(params.width as string) : undefined;
|
||||
const height = params.height ? parseInt(params.height as string) : undefined;
|
||||
|
||||
|
||||
logger.debug(`Retrieving 3D board view from ${angle} angle`);
|
||||
const result = await callKicadScript("get_board_3d_view", {
|
||||
width,
|
||||
height,
|
||||
angle
|
||||
});
|
||||
|
||||
|
||||
if (!result.success) {
|
||||
logger.error(`Failed to retrieve 3D board view: ${result.errorDetails}`);
|
||||
return {
|
||||
@@ -240,7 +240,7 @@ export function registerBoardResources(server: McpServer, callKicadScript: Comma
|
||||
}]
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
logger.debug('Successfully retrieved 3D board view');
|
||||
return {
|
||||
contents: [{
|
||||
@@ -260,7 +260,7 @@ export function registerBoardResources(server: McpServer, callKicadScript: Comma
|
||||
"kicad://board/statistics",
|
||||
async (uri) => {
|
||||
logger.debug('Generating board statistics');
|
||||
|
||||
|
||||
// Get board info
|
||||
const boardResult = await callKicadScript("get_board_info", {});
|
||||
if (!boardResult.success) {
|
||||
@@ -276,7 +276,7 @@ export function registerBoardResources(server: McpServer, callKicadScript: Comma
|
||||
}]
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// Get component list
|
||||
const componentsResult = await callKicadScript("get_component_list", {});
|
||||
if (!componentsResult.success) {
|
||||
@@ -292,7 +292,7 @@ export function registerBoardResources(server: McpServer, callKicadScript: Comma
|
||||
}]
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// Get nets list
|
||||
const netsResult = await callKicadScript("get_nets_list", {});
|
||||
if (!netsResult.success) {
|
||||
@@ -308,7 +308,7 @@ export function registerBoardResources(server: McpServer, callKicadScript: Comma
|
||||
}]
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// Combine all information into statistics
|
||||
const statistics = {
|
||||
board: {
|
||||
@@ -324,7 +324,7 @@ export function registerBoardResources(server: McpServer, callKicadScript: Comma
|
||||
count: netsResult.nets?.length || 0
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
logger.debug('Successfully generated board statistics');
|
||||
return {
|
||||
contents: [{
|
||||
@@ -344,11 +344,11 @@ export function registerBoardResources(server: McpServer, callKicadScript: Comma
|
||||
*/
|
||||
function countComponentTypes(components: any[]): Record<string, number> {
|
||||
const typeCounts: Record<string, number> = {};
|
||||
|
||||
|
||||
for (const component of components) {
|
||||
const type = component.value?.split(' ')[0] || 'Unknown';
|
||||
typeCounts[type] = (typeCounts[type] || 0) + 1;
|
||||
}
|
||||
|
||||
|
||||
return typeCounts;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Component resources for KiCAD MCP server
|
||||
*
|
||||
*
|
||||
* These resources provide information about components on the PCB
|
||||
* to the LLM, enabling better context-aware assistance.
|
||||
*/
|
||||
@@ -13,7 +13,7 @@ type CommandFunction = (command: string, params: Record<string, unknown>) => Pro
|
||||
|
||||
/**
|
||||
* Register component resources with the MCP server
|
||||
*
|
||||
*
|
||||
* @param server MCP server instance
|
||||
* @param callKicadScript Function to call KiCAD script commands
|
||||
*/
|
||||
@@ -29,7 +29,7 @@ export function registerComponentResources(server: McpServer, callKicadScript: C
|
||||
async (uri) => {
|
||||
logger.debug('Retrieving component list');
|
||||
const result = await callKicadScript("get_component_list", {});
|
||||
|
||||
|
||||
if (!result.success) {
|
||||
logger.error(`Failed to retrieve component list: ${result.errorDetails}`);
|
||||
return {
|
||||
@@ -43,7 +43,7 @@ export function registerComponentResources(server: McpServer, callKicadScript: C
|
||||
}]
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
logger.debug(`Successfully retrieved ${result.components?.length || 0} components`);
|
||||
return {
|
||||
contents: [{
|
||||
@@ -69,7 +69,7 @@ export function registerComponentResources(server: McpServer, callKicadScript: C
|
||||
const result = await callKicadScript("get_component_properties", {
|
||||
reference
|
||||
});
|
||||
|
||||
|
||||
if (!result.success) {
|
||||
logger.error(`Failed to retrieve component details: ${result.errorDetails}`);
|
||||
return {
|
||||
@@ -83,7 +83,7 @@ export function registerComponentResources(server: McpServer, callKicadScript: C
|
||||
}]
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
logger.debug(`Successfully retrieved details for component: ${reference}`);
|
||||
return {
|
||||
contents: [{
|
||||
@@ -109,7 +109,7 @@ export function registerComponentResources(server: McpServer, callKicadScript: C
|
||||
const result = await callKicadScript("get_component_connections", {
|
||||
reference
|
||||
});
|
||||
|
||||
|
||||
if (!result.success) {
|
||||
logger.error(`Failed to retrieve component connections: ${result.errorDetails}`);
|
||||
return {
|
||||
@@ -123,7 +123,7 @@ export function registerComponentResources(server: McpServer, callKicadScript: C
|
||||
}]
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
logger.debug(`Successfully retrieved connections for component: ${reference}`);
|
||||
return {
|
||||
contents: [{
|
||||
@@ -144,7 +144,7 @@ export function registerComponentResources(server: McpServer, callKicadScript: C
|
||||
async (uri) => {
|
||||
logger.debug('Retrieving component placement information');
|
||||
const result = await callKicadScript("get_component_placement", {});
|
||||
|
||||
|
||||
if (!result.success) {
|
||||
logger.error(`Failed to retrieve component placement: ${result.errorDetails}`);
|
||||
return {
|
||||
@@ -158,7 +158,7 @@ export function registerComponentResources(server: McpServer, callKicadScript: C
|
||||
}]
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
logger.debug('Successfully retrieved component placement information');
|
||||
return {
|
||||
contents: [{
|
||||
@@ -179,7 +179,7 @@ export function registerComponentResources(server: McpServer, callKicadScript: C
|
||||
async (uri) => {
|
||||
logger.debug('Retrieving component groups');
|
||||
const result = await callKicadScript("get_component_groups", {});
|
||||
|
||||
|
||||
if (!result.success) {
|
||||
logger.error(`Failed to retrieve component groups: ${result.errorDetails}`);
|
||||
return {
|
||||
@@ -193,7 +193,7 @@ export function registerComponentResources(server: McpServer, callKicadScript: C
|
||||
}]
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
logger.debug(`Successfully retrieved ${result.groups?.length || 0} component groups`);
|
||||
return {
|
||||
contents: [{
|
||||
@@ -219,7 +219,7 @@ export function registerComponentResources(server: McpServer, callKicadScript: C
|
||||
const result = await callKicadScript("get_component_visualization", {
|
||||
reference
|
||||
});
|
||||
|
||||
|
||||
if (!result.success) {
|
||||
logger.error(`Failed to generate component visualization: ${result.errorDetails}`);
|
||||
return {
|
||||
@@ -233,7 +233,7 @@ export function registerComponentResources(server: McpServer, callKicadScript: C
|
||||
}]
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
logger.debug(`Successfully generated visualization for component: ${reference}`);
|
||||
return {
|
||||
contents: [{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Resources index for KiCAD MCP server
|
||||
*
|
||||
*
|
||||
* Exports all resource registration functions
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Library resources for KiCAD MCP server
|
||||
*
|
||||
*
|
||||
* These resources provide information about KiCAD component libraries
|
||||
* to the LLM, enabling better context-aware assistance.
|
||||
*/
|
||||
@@ -14,7 +14,7 @@ type CommandFunction = (command: string, params: Record<string, unknown>) => Pro
|
||||
|
||||
/**
|
||||
* Register library resources with the MCP server
|
||||
*
|
||||
*
|
||||
* @param server MCP server instance
|
||||
* @param callKicadScript Function to call KiCAD script commands
|
||||
*/
|
||||
@@ -39,7 +39,7 @@ export function registerLibraryResources(server: McpServer, callKicadScript: Com
|
||||
const limit = Number(params.limit) || undefined;
|
||||
|
||||
logger.debug(`Retrieving component library${filter ? ` with filter: ${filter}` : ''}${library ? ` from library: ${library}` : ''}`);
|
||||
|
||||
|
||||
const result = await callKicadScript("get_component_library", {
|
||||
filter,
|
||||
library,
|
||||
@@ -117,7 +117,7 @@ export function registerLibraryResources(server: McpServer, callKicadScript: Com
|
||||
async (uri, params) => {
|
||||
const { componentId, library } = params;
|
||||
logger.debug(`Retrieving details for component: ${componentId}${library ? ` from library: ${library}` : ''}`);
|
||||
|
||||
|
||||
const result = await callKicadScript("get_component_details", {
|
||||
componentId,
|
||||
library
|
||||
@@ -159,7 +159,7 @@ export function registerLibraryResources(server: McpServer, callKicadScript: Com
|
||||
async (uri, params) => {
|
||||
const { componentId, footprint } = params;
|
||||
logger.debug(`Retrieving footprint for component: ${componentId}${footprint ? ` (${footprint})` : ''}`);
|
||||
|
||||
|
||||
const result = await callKicadScript("get_component_footprint", {
|
||||
componentId,
|
||||
footprint
|
||||
@@ -201,7 +201,7 @@ export function registerLibraryResources(server: McpServer, callKicadScript: Com
|
||||
async (uri, params) => {
|
||||
const { componentId } = params;
|
||||
logger.debug(`Retrieving symbol for component: ${componentId}`);
|
||||
|
||||
|
||||
const result = await callKicadScript("get_component_symbol", {
|
||||
componentId
|
||||
});
|
||||
@@ -255,7 +255,7 @@ export function registerLibraryResources(server: McpServer, callKicadScript: Com
|
||||
async (uri, params) => {
|
||||
const { componentId, footprint } = params;
|
||||
logger.debug(`Retrieving 3D model for component: ${componentId}${footprint ? ` (${footprint})` : ''}`);
|
||||
|
||||
|
||||
const result = await callKicadScript("get_component_3d_model", {
|
||||
componentId,
|
||||
footprint
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Project resources for KiCAD MCP server
|
||||
*
|
||||
*
|
||||
* These resources provide information about the KiCAD project
|
||||
* to the LLM, enabling better context-aware assistance.
|
||||
*/
|
||||
@@ -13,7 +13,7 @@ type CommandFunction = (command: string, params: Record<string, unknown>) => Pro
|
||||
|
||||
/**
|
||||
* Register project resources with the MCP server
|
||||
*
|
||||
*
|
||||
* @param server MCP server instance
|
||||
* @param callKicadScript Function to call KiCAD script commands
|
||||
*/
|
||||
@@ -29,7 +29,7 @@ export function registerProjectResources(server: McpServer, callKicadScript: Com
|
||||
async (uri) => {
|
||||
logger.debug('Retrieving project information');
|
||||
const result = await callKicadScript("get_project_info", {});
|
||||
|
||||
|
||||
if (!result.success) {
|
||||
logger.error(`Failed to retrieve project information: ${result.errorDetails}`);
|
||||
return {
|
||||
@@ -43,7 +43,7 @@ export function registerProjectResources(server: McpServer, callKicadScript: Com
|
||||
}]
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
logger.debug('Successfully retrieved project information');
|
||||
return {
|
||||
contents: [{
|
||||
@@ -64,7 +64,7 @@ export function registerProjectResources(server: McpServer, callKicadScript: Com
|
||||
async (uri) => {
|
||||
logger.debug('Retrieving project properties');
|
||||
const result = await callKicadScript("get_project_properties", {});
|
||||
|
||||
|
||||
if (!result.success) {
|
||||
logger.error(`Failed to retrieve project properties: ${result.errorDetails}`);
|
||||
return {
|
||||
@@ -78,7 +78,7 @@ export function registerProjectResources(server: McpServer, callKicadScript: Com
|
||||
}]
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
logger.debug('Successfully retrieved project properties');
|
||||
return {
|
||||
contents: [{
|
||||
@@ -99,7 +99,7 @@ export function registerProjectResources(server: McpServer, callKicadScript: Com
|
||||
async (uri) => {
|
||||
logger.debug('Retrieving project files');
|
||||
const result = await callKicadScript("get_project_files", {});
|
||||
|
||||
|
||||
if (!result.success) {
|
||||
logger.error(`Failed to retrieve project files: ${result.errorDetails}`);
|
||||
return {
|
||||
@@ -113,7 +113,7 @@ export function registerProjectResources(server: McpServer, callKicadScript: Com
|
||||
}]
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
logger.debug(`Successfully retrieved ${result.files?.length || 0} project files`);
|
||||
return {
|
||||
contents: [{
|
||||
@@ -134,7 +134,7 @@ export function registerProjectResources(server: McpServer, callKicadScript: Com
|
||||
async (uri) => {
|
||||
logger.debug('Retrieving project status');
|
||||
const result = await callKicadScript("get_project_status", {});
|
||||
|
||||
|
||||
if (!result.success) {
|
||||
logger.error(`Failed to retrieve project status: ${result.errorDetails}`);
|
||||
return {
|
||||
@@ -148,7 +148,7 @@ export function registerProjectResources(server: McpServer, callKicadScript: Com
|
||||
}]
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
logger.debug('Successfully retrieved project status');
|
||||
return {
|
||||
contents: [{
|
||||
@@ -168,7 +168,7 @@ export function registerProjectResources(server: McpServer, callKicadScript: Com
|
||||
"kicad://project/summary",
|
||||
async (uri) => {
|
||||
logger.debug('Generating project summary');
|
||||
|
||||
|
||||
// Get project info
|
||||
const infoResult = await callKicadScript("get_project_info", {});
|
||||
if (!infoResult.success) {
|
||||
@@ -184,7 +184,7 @@ export function registerProjectResources(server: McpServer, callKicadScript: Com
|
||||
}]
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// Get board info
|
||||
const boardResult = await callKicadScript("get_board_info", {});
|
||||
if (!boardResult.success) {
|
||||
@@ -200,7 +200,7 @@ export function registerProjectResources(server: McpServer, callKicadScript: Com
|
||||
}]
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// Get component list
|
||||
const componentsResult = await callKicadScript("get_component_list", {});
|
||||
if (!componentsResult.success) {
|
||||
@@ -216,7 +216,7 @@ export function registerProjectResources(server: McpServer, callKicadScript: Com
|
||||
}]
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// Combine all information into a summary
|
||||
const summary = {
|
||||
project: infoResult.project,
|
||||
@@ -230,7 +230,7 @@ export function registerProjectResources(server: McpServer, callKicadScript: Com
|
||||
types: countComponentTypes(componentsResult.components || [])
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
logger.debug('Successfully generated project summary');
|
||||
return {
|
||||
contents: [{
|
||||
@@ -250,11 +250,11 @@ export function registerProjectResources(server: McpServer, callKicadScript: Com
|
||||
*/
|
||||
function countComponentTypes(components: any[]): Record<string, number> {
|
||||
const typeCounts: Record<string, number> = {};
|
||||
|
||||
|
||||
for (const component of components) {
|
||||
const type = component.value?.split(' ')[0] || 'Unknown';
|
||||
typeCounts[type] = (typeCounts[type] || 0) + 1;
|
||||
}
|
||||
|
||||
|
||||
return typeCounts;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Board management tools for KiCAD MCP server
|
||||
*
|
||||
*
|
||||
* These tools handle board setup, layer management, and board properties
|
||||
*/
|
||||
|
||||
@@ -13,13 +13,13 @@ type CommandFunction = (command: string, params: Record<string, unknown>) => Pro
|
||||
|
||||
/**
|
||||
* Register board management tools with the MCP server
|
||||
*
|
||||
*
|
||||
* @param server MCP server instance
|
||||
* @param callKicadScript Function to call KiCAD script commands
|
||||
*/
|
||||
export function registerBoardTools(server: McpServer, callKicadScript: CommandFunction): void {
|
||||
logger.info('Registering board management tools');
|
||||
|
||||
|
||||
// ------------------------------------------------------
|
||||
// Set Board Size Tool
|
||||
// ------------------------------------------------------
|
||||
@@ -37,7 +37,7 @@ export function registerBoardTools(server: McpServer, callKicadScript: CommandFu
|
||||
height,
|
||||
unit
|
||||
});
|
||||
|
||||
|
||||
return {
|
||||
content: [{
|
||||
type: "text",
|
||||
@@ -70,7 +70,7 @@ export function registerBoardTools(server: McpServer, callKicadScript: CommandFu
|
||||
position,
|
||||
number
|
||||
});
|
||||
|
||||
|
||||
return {
|
||||
content: [{
|
||||
type: "text",
|
||||
@@ -91,7 +91,7 @@ export function registerBoardTools(server: McpServer, callKicadScript: CommandFu
|
||||
async ({ layer }) => {
|
||||
logger.debug(`Setting active layer to: ${layer}`);
|
||||
const result = await callKicadScript("set_active_layer", { layer });
|
||||
|
||||
|
||||
return {
|
||||
content: [{
|
||||
type: "text",
|
||||
@@ -110,7 +110,7 @@ export function registerBoardTools(server: McpServer, callKicadScript: CommandFu
|
||||
async () => {
|
||||
logger.debug('Getting board information');
|
||||
const result = await callKicadScript("get_board_info", {});
|
||||
|
||||
|
||||
return {
|
||||
content: [{
|
||||
type: "text",
|
||||
@@ -129,7 +129,7 @@ export function registerBoardTools(server: McpServer, callKicadScript: CommandFu
|
||||
async () => {
|
||||
logger.debug('Getting layer list');
|
||||
const result = await callKicadScript("get_layer_list", {});
|
||||
|
||||
|
||||
return {
|
||||
content: [{
|
||||
type: "text",
|
||||
@@ -205,7 +205,7 @@ export function registerBoardTools(server: McpServer, callKicadScript: CommandFu
|
||||
diameter,
|
||||
padDiameter
|
||||
});
|
||||
|
||||
|
||||
return {
|
||||
content: [{
|
||||
type: "text",
|
||||
@@ -244,7 +244,7 @@ export function registerBoardTools(server: McpServer, callKicadScript: CommandFu
|
||||
rotation,
|
||||
style
|
||||
});
|
||||
|
||||
|
||||
return {
|
||||
content: [{
|
||||
type: "text",
|
||||
@@ -284,7 +284,7 @@ export function registerBoardTools(server: McpServer, callKicadScript: CommandFu
|
||||
minWidth,
|
||||
padConnection
|
||||
});
|
||||
|
||||
|
||||
return {
|
||||
content: [{
|
||||
type: "text",
|
||||
@@ -305,7 +305,7 @@ export function registerBoardTools(server: McpServer, callKicadScript: CommandFu
|
||||
async ({ unit }) => {
|
||||
logger.debug('Getting board extents');
|
||||
const result = await callKicadScript("get_board_extents", { unit });
|
||||
|
||||
|
||||
return {
|
||||
content: [{
|
||||
type: "text",
|
||||
@@ -334,7 +334,7 @@ export function registerBoardTools(server: McpServer, callKicadScript: CommandFu
|
||||
height,
|
||||
format
|
||||
});
|
||||
|
||||
|
||||
return {
|
||||
content: [{
|
||||
type: "text",
|
||||
@@ -382,4 +382,3 @@ export function registerBoardTools(server: McpServer, callKicadScript: CommandFu
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,16 +11,16 @@ type CommandFunction = (command: string, params: any) => Promise<any>;
|
||||
|
||||
/**
|
||||
* Register component management tools with the MCP server
|
||||
*
|
||||
*
|
||||
* @param server MCP server instance
|
||||
* @param callKicadScript Function to call KiCAD script commands
|
||||
*/
|
||||
export function registerComponentTools(server: McpServer, callKicadScript: CommandFunction): void {
|
||||
logger.info('Registering component management tools');
|
||||
|
||||
|
||||
// ------------------------------------------------------
|
||||
// Place Component Tool
|
||||
// ------------------------------------------------------
|
||||
server.registerTool({
|
||||
name: "place_component",
|
||||
description: "Places a component on the PCB at the specified location",
|
||||
description: "Places a component on the PCB at the specified location",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Design rules tools for KiCAD MCP server
|
||||
*
|
||||
*
|
||||
* These tools handle design rule checking and configuration
|
||||
*/
|
||||
|
||||
@@ -13,13 +13,13 @@ type CommandFunction = (command: string, params: Record<string, unknown>) => Pro
|
||||
|
||||
/**
|
||||
* Register design rule tools with the MCP server
|
||||
*
|
||||
*
|
||||
* @param server MCP server instance
|
||||
* @param callKicadScript Function to call KiCAD script commands
|
||||
*/
|
||||
export function registerDesignRuleTools(server: McpServer, callKicadScript: CommandFunction): void {
|
||||
logger.info('Registering design rule tools');
|
||||
|
||||
|
||||
// ------------------------------------------------------
|
||||
// Set Design Rules Tool
|
||||
// ------------------------------------------------------
|
||||
@@ -44,7 +44,7 @@ export function registerDesignRuleTools(server: McpServer, callKicadScript: Comm
|
||||
async (params) => {
|
||||
logger.debug('Setting design rules');
|
||||
const result = await callKicadScript("set_design_rules", params);
|
||||
|
||||
|
||||
return {
|
||||
content: [{
|
||||
type: "text",
|
||||
@@ -63,7 +63,7 @@ export function registerDesignRuleTools(server: McpServer, callKicadScript: Comm
|
||||
async () => {
|
||||
logger.debug('Getting design rules');
|
||||
const result = await callKicadScript("get_design_rules", {});
|
||||
|
||||
|
||||
return {
|
||||
content: [{
|
||||
type: "text",
|
||||
@@ -84,7 +84,7 @@ export function registerDesignRuleTools(server: McpServer, callKicadScript: Comm
|
||||
async ({ reportPath }) => {
|
||||
logger.debug('Running DRC check');
|
||||
const result = await callKicadScript("run_drc", { reportPath });
|
||||
|
||||
|
||||
return {
|
||||
content: [{
|
||||
type: "text",
|
||||
@@ -127,7 +127,7 @@ export function registerDesignRuleTools(server: McpServer, callKicadScript: Comm
|
||||
diff_pair_gap,
|
||||
nets
|
||||
});
|
||||
|
||||
|
||||
return {
|
||||
content: [{
|
||||
type: "text",
|
||||
@@ -152,7 +152,7 @@ export function registerDesignRuleTools(server: McpServer, callKicadScript: Comm
|
||||
net,
|
||||
netClass
|
||||
});
|
||||
|
||||
|
||||
return {
|
||||
content: [{
|
||||
type: "text",
|
||||
@@ -183,7 +183,7 @@ export function registerDesignRuleTools(server: McpServer, callKicadScript: Comm
|
||||
minViaDiameter,
|
||||
minViaDrill
|
||||
});
|
||||
|
||||
|
||||
return {
|
||||
content: [{
|
||||
type: "text",
|
||||
@@ -226,7 +226,7 @@ export function registerDesignRuleTools(server: McpServer, callKicadScript: Comm
|
||||
item1,
|
||||
item2
|
||||
});
|
||||
|
||||
|
||||
return {
|
||||
content: [{
|
||||
type: "text",
|
||||
@@ -247,7 +247,7 @@ export function registerDesignRuleTools(server: McpServer, callKicadScript: Comm
|
||||
async ({ severity }) => {
|
||||
logger.debug('Getting DRC violations');
|
||||
const result = await callKicadScript("get_drc_violations", { severity });
|
||||
|
||||
|
||||
return {
|
||||
content: [{
|
||||
type: "text",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Export tools for KiCAD MCP server
|
||||
*
|
||||
*
|
||||
* These tools handle exporting PCB data to various formats
|
||||
*/
|
||||
|
||||
@@ -13,13 +13,13 @@ type CommandFunction = (command: string, params: Record<string, unknown>) => Pro
|
||||
|
||||
/**
|
||||
* Register export tools with the MCP server
|
||||
*
|
||||
*
|
||||
* @param server MCP server instance
|
||||
* @param callKicadScript Function to call KiCAD script commands
|
||||
*/
|
||||
export function registerExportTools(server: McpServer, callKicadScript: CommandFunction): void {
|
||||
logger.info('Registering export tools');
|
||||
|
||||
|
||||
// ------------------------------------------------------
|
||||
// Export Gerber Tool
|
||||
// ------------------------------------------------------
|
||||
@@ -43,7 +43,7 @@ export function registerExportTools(server: McpServer, callKicadScript: CommandF
|
||||
generateMapFile,
|
||||
useAuxOrigin
|
||||
});
|
||||
|
||||
|
||||
return {
|
||||
content: [{
|
||||
type: "text",
|
||||
@@ -74,7 +74,7 @@ export function registerExportTools(server: McpServer, callKicadScript: CommandF
|
||||
frameReference,
|
||||
pageSize
|
||||
});
|
||||
|
||||
|
||||
return {
|
||||
content: [{
|
||||
type: "text",
|
||||
@@ -103,7 +103,7 @@ export function registerExportTools(server: McpServer, callKicadScript: CommandF
|
||||
blackAndWhite,
|
||||
includeComponents
|
||||
});
|
||||
|
||||
|
||||
return {
|
||||
content: [{
|
||||
type: "text",
|
||||
@@ -136,7 +136,7 @@ export function registerExportTools(server: McpServer, callKicadScript: CommandF
|
||||
includeSolderMask,
|
||||
includeSilkscreen
|
||||
});
|
||||
|
||||
|
||||
return {
|
||||
content: [{
|
||||
type: "text",
|
||||
@@ -165,7 +165,7 @@ export function registerExportTools(server: McpServer, callKicadScript: CommandF
|
||||
groupByValue,
|
||||
includeAttributes
|
||||
});
|
||||
|
||||
|
||||
return {
|
||||
content: [{
|
||||
type: "text",
|
||||
@@ -190,7 +190,7 @@ export function registerExportTools(server: McpServer, callKicadScript: CommandF
|
||||
outputPath,
|
||||
format
|
||||
});
|
||||
|
||||
|
||||
return {
|
||||
content: [{
|
||||
type: "text",
|
||||
@@ -219,7 +219,7 @@ export function registerExportTools(server: McpServer, callKicadScript: CommandF
|
||||
units,
|
||||
side
|
||||
});
|
||||
|
||||
|
||||
return {
|
||||
content: [{
|
||||
type: "text",
|
||||
@@ -246,7 +246,7 @@ export function registerExportTools(server: McpServer, callKicadScript: CommandF
|
||||
includeComponents,
|
||||
useRelativePaths
|
||||
});
|
||||
|
||||
|
||||
return {
|
||||
content: [{
|
||||
type: "text",
|
||||
|
||||
Reference in New Issue
Block a user