-
Notifications
You must be signed in to change notification settings - Fork 271
feat(mcp): add modular MCP server & Inspector/Claude integration #71
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
base: main
Are you sure you want to change the base?
Conversation
hii @devroopsaha744I appreciate your efforts and contributions, but I was unable to find the previous discussion for this feature! Could you provide the issue number or the discussion number? |
|
hi @alfaarghya Thanks for the feedback! I wasn’t aware that prior discussion or an issue was required before opening a feature PR. The goal of this PR is to add an MCP (Model Context Protocol) server layer so that the API can be accessed directly by AI agents and LLMs through Claude Desktop or similar tools. Shall I open a discussion for this feature and then link it back here (if approved)? |
|
Yes, in every open-source project, you first need to ask the maintainer or the community about the feature you want to add by posting an issue or opening up a discussion. So, please open up some discussion or feature(issue), so that others can give their opinions and also let's discuss if we need this feature or not! Meanwhile, I will be going through your changes and reviewing your code. |
|
hi @alfaarghya I’ve opened a detailed discussion outlining this feature proposal here: #73 It covers the motivation, technical breakdown, and rationale behind adding the MCP server for AI Agent and LLM integration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hii @devroopsaha744
Your implementation looks solid! But we need some changes before I merge it!
- add proper comments for your functions
- move
typeorinterfaceto other directory or file. - Provide instructions for other OS like Linux and MAC OS
mcp/index.ts
Outdated
| type Mode = 'all' | 'users' | 'problems' | 'discussions'; | ||
|
|
||
| type ModuleConfig = { | ||
| modules: ToolModule[]; | ||
| name: string; | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw you are putting types in the files themselves. But I would suggest trying to keep them in a separate file or directory(like mcp/types.ts).
README.md
Outdated
| 1. Open `%AppData%/Claude/claude_desktop_config.json`. | ||
| 2. Add a server entry pointing at the built file. Example: | ||
|
|
||
| ```json | ||
| { | ||
| "mcpServers": { | ||
| "leetcode-suite": { | ||
| "command": "node", | ||
| "args": ["C:\\path\\to\\alfa-leetcode-api\\dist\\mcp\\index.js"] | ||
| } | ||
| } | ||
| } | ||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is how we can configure the MCP server for Windows. What about Linux and MAC OS?
Need instructions for those!
mcp/leetCodeService.ts
Outdated
| type SubmissionArgs = { username: string; limit?: number }; | ||
| type CalendarArgs = { username: string; year: number }; | ||
| type ProblemArgs = { limit?: number; skip?: number; tags?: string; difficulty?: string }; | ||
| type DiscussCommentsArgs = { topicId: number; orderBy?: string; pageNo?: number; numPerPage?: number }; | ||
|
|
||
| type Variables = Record<string, unknown>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep types in a separate file(mcp/types.ts)
mcp/serverUtils.ts
Outdated
| import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; | ||
| import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'; | ||
|
|
||
| type GraphQLParams = Record<string, unknown>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep types in a separate file(mcp/types.ts)
mcp/serverUtils.ts
Outdated
| type GraphQLParams = Record<string, unknown>; | ||
|
|
||
| const GRAPHQL_ENDPOINT = 'https://leetcode.com/graphql'; | ||
| export const SERVER_VERSION = '2.0.1'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current server version is 2.0.2.
But why do we need this?
mcp/serverUtils.ts
Outdated
| export type ToolResponse = { content: { type: 'text'; text: string }[] }; | ||
|
|
||
| export type ToolExecutor = () => Promise<unknown>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep types in a separate file(mcp/types.ts)
… MCP setup client‑agnostic
|
Hi @alfaarghya first of all sorry the delay. I have implemented the changes as per your request:
can you please review them |
|
Hi @devroopsaha744, I'll review your changes, but meanwhile, please resolve the merge conflicts on package-lock.json. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolve these merge conflicts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hii @devroopsaha744, your code looks solid, and I will approve the PR. But first, please resolve the conflict!
|
Hi @alfaarghya , I have resolved the conflicts. let me know if you need anything else! |
Summary
This PR adds a modular Model Context Protocol (MCP) server that exposes LeetCode functionality as MCP tools and documents how to run and inspect it with the MCP Inspector and Claude Desktop. The MCP implementation is split into three modules: users, problems, and discussions. It includes a shared server bootstrap, an Inspector launcher, and README updates with setup and usage instructions.
What changed
Add modular MCP entrypoint and bootstrap
Add tool modules
Dev and inspect helpers
mcp:inspectDocumentation
Naming and validation
Tool identifiers updated to conform to MCP name pattern (only alphanumeric, underscore, hyphen). Example:
leetcode_user_dataFiles added or modified (high level)
Added
Modified
Rationale
How to test
Install and build
Configure Claude Desktop
%AppData%\Claude\claude_desktop_config.json.{ "mcpServers": { "leetcode-suite": { "command": "node", "args": ["C:\\path\\to\\alfa-leetcode-api\\dist\\mcp\\index.js"] } } }Demo
Notes and compatibility
Checklist
npm run build