UNPKG

@coding-cloud/coding-cloud-mcp-server

Version:

TypeScript Model Context Protocol (MCP) server for coding-cloud.com API.

83 lines (78 loc) 3.7 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); Object.defineProperty(exports, "__esModule", { value: true }); const logger_util_js_1 = require("../utils/logger.util.js"); const error_util_js_1 = require("../utils/error.util.js"); const codingCloudApiController = __importStar(require("../controllers/coding-cloud-api.controller.js")); /** * Register Coding Cloud API CLI commands * @param program The Commander program instance */ function register(program) { const cliLogger = logger_util_js_1.Logger.forContext('cli/coding-cloud-api.cli.ts', 'register'); cliLogger.debug(`Registering Coding Cloud API CLI commands...`); program .command('search-code') .description(`Search for code snippets using the Coding Cloud API. PURPOSE: Find relevant code examples or snippets based on a natural language query. Use Case: Quickly find code implementations, usage examples, or solutions to programming problems. Output: Formatted Markdown containing the top code snippets found, including title/identifier and code content. Examples: $ mcp-coding-cloud search-code "python dictionary example" $ mcp-coding-cloud search-code "React useState hook" --limit 3`) .argument('<query>', 'The search query string.') .option('-l, --limit <number>', 'Maximum number of results to return', (value) => parseInt(value, 10)) .action(async (query, options) => { const actionLogger = logger_util_js_1.Logger.forContext('cli/coding-cloud-api.cli.ts', 'search-code:action'); actionLogger.info(`Executing search-code command...`); actionLogger.debug(`Query: ${query}, Options: ${JSON.stringify(options)}`); try { // Map CLI arguments to controller options const controllerOptions = { limit: options.limit, }; // Call the controller const result = await codingCloudApiController.searchSnippets(query, controllerOptions); // Display the output console.log(result.content); } catch (error) { actionLogger.error(`Error searching code snippets for query: ${query}`, error); (0, error_util_js_1.handleCliError)(error); } }); cliLogger.debug('Coding Cloud API CLI commands registered.'); } exports.default = { register };