🔗 index.ts
This commit is contained in:
@@ -1,30 +1,27 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
/**
|
||||||
|
* STDIO entrypoint — for local use with Claude Desktop, Claude Code, etc.
|
||||||
|
*
|
||||||
|
* Usage:
|
||||||
|
* node dist/index.js
|
||||||
|
* CLAUDE_CODE_SRC_ROOT=/path/to/src node dist/index.js
|
||||||
|
*/
|
||||||
|
|
||||||
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
||||||
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
||||||
import {
|
import { createServer, validateSrcRoot, SRC_ROOT } from "./server.js";
|
||||||
CallToolRequestSchema,
|
|
||||||
ListToolsRequestSchema,
|
|
||||||
ListResourcesRequestSchema,
|
|
||||||
ReadResourceRequestSchema,
|
|
||||||
ListResourceTemplatesRequestSchema,
|
|
||||||
ListPromptsRequestSchema,
|
|
||||||
GetPromptRequestSchema,
|
|
||||||
} from "@modelcontextprotocol/sdk/types.js";
|
|
||||||
import * as fs from "node:fs/promises";
|
|
||||||
import * as path from "node:path";
|
|
||||||
import { fileURLToPath } from "node:url";
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
async function main() {
|
||||||
// Configuration
|
await validateSrcRoot();
|
||||||
// ---------------------------------------------------------------------------
|
const server = createServer();
|
||||||
|
const transport = new StdioServerTransport();
|
||||||
|
await server.connect(transport);
|
||||||
|
console.error(`Claude Code Explorer MCP (stdio) started — src: ${SRC_ROOT}`);
|
||||||
|
}
|
||||||
|
|
||||||
const __filename = fileURLToPath(import.meta.url);
|
main().catch((err) => {
|
||||||
const __dirname = path.dirname(__filename);
|
console.error("Fatal error:", err);
|
||||||
|
process.exit(1);
|
||||||
const SRC_ROOT = path.resolve(
|
});
|
||||||
process.env.CLAUDE_CODE_SRC_ROOT ?? path.join(__dirname, "..", "..", "src")
|
|
||||||
);
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// Helpers
|
// Helpers
|
||||||
@@ -986,3 +983,4 @@ main().catch((err) => {
|
|||||||
console.error("Fatal error:", err);
|
console.error("Fatal error:", err);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user