more mcp stuff

This commit is contained in:
Eric Allam
2025-07-31 15:56:33 +01:00
parent 32af62e124
commit df907ff0aa
4 changed files with 55 additions and 37 deletions
-19
View File
@@ -1,19 +0,0 @@
[2025-07-31T11:21:07.328Z] get_project_details - [ { roots: { roots: [] }, projectRef: 'asdasdjaskdjasd' } ]
[2025-07-31T11:26:08.494Z][version=0.16.2 capabilities=sampling,elicitation,roots] get_project_details - [ { roots: { roots: [] }, projectRef: 'asdaasd' } ]
[2025-07-31T11:27:06.469Z][client=mcp-inspector version=0.16.2 capabilities=sampling,elicitation,roots] get_project_details - [ { roots: { roots: [] }, projectRef: 'asdadas' } ]
[2025-07-31T11:28:40.476Z][client=mcp-inspector version=0.16.2 capabilities=sampling,elicitation,roots] get_project_details - [
{
roots: { roots: [] },
projectRef: 'asdadasd',
extra: {
signal: AbortSignal { aborted: false },
sessionId: undefined,
_meta: { progressToken: 1 },
sendNotification: [Function: sendNotification],
sendRequest: [Function: sendRequest],
authInfo: undefined,
requestId: 1,
requestInfo: undefined
}
}
]
+9 -18
View File
@@ -7,6 +7,8 @@ import { login } from "./login.js";
import { performSearch } from "../mcp/mintlifyClient.js";
import { logger } from "../utilities/logger.js";
import { FileLogger } from "../mcp/logger.js";
import { McpContext } from "../mcp/context.js";
import { registerGetProjectDetailsTool } from "../mcp/tools.js";
const McpCommandOptions = CommonCommandOptions.extend({
projectRef: z.string().optional(),
@@ -54,6 +56,12 @@ export async function mcpCommand(options: McpCommandOptions) {
? new FileLogger(options.logFile, server)
: undefined;
const context = new McpContext(server, {
login: authorization,
projectRef: options.projectRef,
fileLogger,
});
server.registerTool(
"search_docs",
{
@@ -69,24 +77,7 @@ export async function mcpCommand(options: McpCommandOptions) {
}
);
server.registerTool(
"get_project_details",
{
description: "Get the details of the project",
inputSchema: {
projectRef: z.string().optional(),
},
},
async ({ projectRef }, extra) => {
const roots = await server.server.listRoots();
fileLogger?.log("get_project_details", { roots, projectRef, extra });
return {
content: [{ type: "text", text: "Not implemented" }],
};
}
);
registerGetProjectDetailsTool(context);
// Start receiving messages on stdin and sending messages on stdout
const transport = new StdioServerTransport();
+23
View File
@@ -0,0 +1,23 @@
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { FileLogger } from "./logger.js";
import { LoginResult } from "../utilities/session.js";
export type McpContextOptions = {
login: LoginResult;
projectRef?: string;
fileLogger?: FileLogger;
};
export class McpContext {
public readonly server: McpServer;
public readonly options: McpContextOptions;
constructor(server: McpServer, options: McpContextOptions) {
this.server = server;
this.options = options;
}
get logger() {
return this.options.fileLogger;
}
}
+23
View File
@@ -0,0 +1,23 @@
import z from "zod";
import { McpContext } from "./context.js";
export function registerGetProjectDetailsTool(context: McpContext) {
context.server.registerTool(
"get_project_details",
{
description: "Get the details of the project",
inputSchema: {
projectRef: z.string().optional(),
},
},
async ({ projectRef }, extra) => {
const roots = await context.server.server.listRoots();
context.logger?.log("get_project_details", { roots, projectRef, extra });
return {
content: [{ type: "text", text: "Not implemented" }],
};
}
);
}