@hpbyte/h-codex-mcp
Version:
Model Context Protocol for h-codexx
45 lines • 1.67 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const h_codex_core_1 = require("@hpbyte/h-codex-core");
const schemas_1 = require("./schemas");
class CodeIndexTool {
register(server) {
server.registerTool('code-index', {
title: 'Index codebase',
description: 'Explore and index code files in a directory path',
inputSchema: schemas_1.CodeIndexInputSchema,
}, async ({ path }) => {
try {
const result = await h_codex_core_1.indexer.index(path);
return {
content: [
{
type: 'text',
text: JSON.stringify(result, (_, value) => {
if (typeof value === 'function' ||
value instanceof RegExp ||
value instanceof Error) {
return value.toString();
}
return value;
}, 2),
},
],
};
}
catch (error) {
return {
content: [
{
type: 'text',
text: `Error indexing code: ${error instanceof Error ? error.message : String(error)}`,
},
],
};
}
});
}
}
const tool = new CodeIndexTool();
exports.default = tool;
//# sourceMappingURL=code-index.js.map