Skip to content

mcp #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

mcp #38

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"pub:beta": "pnpm build && npm publish --tag beta --access public",
"pub:next": "pnpm build && npm publish --tag next --access public",
"pub:release": "pnpm build && npm publish --access public",
"mcp-inspector": "CLIENT_PORT=8080 SERVER_PORT=9000 pnpx @modelcontextprotocol/inspector node ./dist/index.js mcp",
"test": "vitest run",
"test:watch": "vitest",
"test:coverage": "vitest run --coverage"
Expand All @@ -60,6 +61,7 @@
"@clack/core": "^0.3.4",
"@clack/prompts": "^0.7.0",
"@ianvs/prettier-plugin-sort-imports": "^4.2.1",
"@modelcontextprotocol/sdk": "^1.7.0",
"@proofgeist/fmdapi": "^4.1.5",
"@types/glob": "^8.1.0",
"axios": "^1.7.3",
Expand Down Expand Up @@ -99,6 +101,7 @@
"@types/randomstring": "^1.3.0",
"@types/react": "^18.3.11",
"@types/semver": "^7.5.8",
"@vitest/coverage-v8": "^1.4.0",
"drizzle-kit": "^0.21.4",
"drizzle-orm": "^0.30.10",
"mysql2": "^3.9.7",
Expand All @@ -116,7 +119,6 @@
"type-fest": "^3.13.1",
"typescript": "^5.6.3",
"vitest": "^1.4.0",
"@vitest/coverage-v8": "^1.4.0",
"zod": "^3.23.8"
"zod": "^3.24.2"
}
}
2 changes: 2 additions & 0 deletions cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { makeUpgradeCommand } from "./cli/update/makeUpgradeCommand.js";
import { UserAbortedError } from "./cli/utils.js";
import { npmName } from "./consts.js";
import { ciOption } from "./globalOptions.js";
import { makeMcpCommand } from "./mcp/command.js";
import { initProgramState, state } from "./state.js";
import { getVersion } from "./utils/getProofKitVersion.js";
import { getSettings, type Settings } from "./utils/parseSettings.js";
Expand Down Expand Up @@ -67,6 +68,7 @@ const main = async () => {
program.addCommand(makeTypegenCommand());
program.addCommand(makeDeployCommand());
program.addCommand(makeUpgradeCommand());
program.addCommand(makeMcpCommand());

await program.parseAsync(process.argv);
process.exit(0);
Expand Down
15 changes: 15 additions & 0 deletions cli/src/mcp/command.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { program } from "commander";

import { makeServer } from "./server.js";

export function makeMcpCommand() {
return program.command("mcp").action(async () => {
const server = makeServer();
const transport = new StdioServerTransport();
await server.connect(transport);

// eslint-disable-next-line @typescript-eslint/no-empty-function
await new Promise(() => {}); // keep the process running
});
}
50 changes: 50 additions & 0 deletions cli/src/mcp/server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import {
McpServer,
ResourceTemplate,
} from "@modelcontextprotocol/sdk/server/mcp.js";
import { z } from "zod";

import { getVersion } from "~/utils/getProofKitVersion.js";

interface ScaffoldPageParams {
name: string;
path: string;
techStack?: string;
template?: string;
}

interface ScaffoldProjectParams {
name: string;
path: string;
techStack?: string;
template?: string;
}

export function makeServer() {
const server = new McpServer({
name: "proofkit",
version: getVersion(),
});

server.tool(
"init",
"description",
{ name: z.string(), type: z.enum(["browser", "wv"]) },
({ name, type }) => {
console.log("create new project", name, type);
return { content: [{ type: "text", text: "Project created" }] };
}
);

server.resource(
"project-info",
new ResourceTemplate("proofkit://info?path={path}", { list: undefined }),
async (uri, { path }) => {
return {
contents: [{ uri: uri.href, text: `Project info for ${path}` }],
};
}
);

return server;
}
Loading