NowCoder ACM Problem MCP Server
Enables interaction with public NowCoder ACM problem pages. Supports fetching problem data and checking health status.
README
NowCoder MCP Server
Bring NowCoder ACM problems and login-aware workflows directly into VS Code agents through a typed local MCP server.
Quick Start
git clone https://github.com/ketherworks/nowcoder-oj-mcp.git
cd nowcoder-oj-mcp
npm ci
npm run build
Open MCP: Open User Configuration in VS Code and add:
{
"inputs": [
{
"type": "promptString",
"id": "nowcoder-cookie",
"description": "NowCoder Cookie request-header value",
"password": true
}
],
"servers": {
"nowcoder": {
"type": "stdio",
"command": "node",
"args": ["C:/path/to/nowcoder-oj-mcp/packages/nowcoder/dist/index.js"],
"env": {
"NOWCODER_SESSION_COOKIE": "${input:nowcoder-cookie}",
"COMPETITIVE_COMPANION_PORT": "10043"
}
}
}
}
Start the server from MCP: List Servers. VS Code prompts for the Cookie once and stores the input securely. For public reads, remove the Cookie input and NOWCODER_SESSION_COOKIE; the browser-import port can stay.
Try these prompts:
Search NowCoder for "binary graph" and return the first 10 problems.
Import NowCoder problem NC218144.
Open a NowCoder browser-import window.
Read my NowCoder competition profile and latest 20 submissions.
Run the first sample for my saved main.cpp on NowCoder.
Prepare my saved main.cpp for submission.
For browser import, install Competitive Companion, set its custom port to 10043, call oj_open_import_window, click the green plus on the problem page, then call oj_complete_import. The listener closes after one problem.
Tools
oj_capabilities: discovers the active transport, authentication mode, operation risk, and language support.oj_health: reports transport and parser health from real adapter activity.oj_fetch_problem: converts an official problem page into a typedOjProblemDocumentwith statement, limits, samples, tags, provenance, and hashes.oj_search_problems: searches the official ACM catalog by keyword with bounded cursor pagination.oj_open_import_window: opens a one-shot Competitive Companion receiver on loopback for up to 60 seconds.oj_complete_import: receives the browser task, samples, and limits as a typed import preview.oj_fetch_profile: reads a compact competition profile by numeric ID, or resolves the signed-in account.oj_list_submissions: pages through verdict, problem, language, time, memory, code length, and submission time without reading source code.oj_platform_run: uploads an immutable code artifact after confirmation and runs one sample on NowCoder.oj_poll_run: continues a dispatched platform run byrequestIdwithout uploading code again.oj_prepare_submission: validates account, problem, language, file hash, and code size, then creates a two-minute preview without submitting.oj_commit_submission: shows an MCP-native confirmation form, obtains a fresh short-lived token, and submits exactly once after acceptance.oj_poll_submission: polls a submission created by this process and never resubmits it.nowcoder_auth_status: validates the local session and returns a redacted login state.
Submission Flow
- Save the source file, then call
oj_prepare_submission. The server resolves itsfile:URI and verifies the on-disk bytes, canonical problem, account or team, contest, language, and SHA-256. - Call
oj_commit_submission; VS Code displays the confirmation form. - Accept to create one real submission, then call
oj_poll_submissionfor the verdict.
Declining or cancelling creates no submission. An ambiguous network timeout returns outcome_unknown and is never retried automatically.
Problem IDs
Use a URL or one of the compact IDs below:
NC218144 -> https://ac.nowcoder.com/acm/problem/218144
11244/A -> https://ac.nowcoder.com/acm/contest/11244/A
Login
Sign in to NowCoder in a browser, inspect a request to ac.nowcoder.com, and use its complete Cookie request-header value when VS Code prompts. Restart the MCP server after rotating the session.
The Cookie is read once at process startup and never returned through MCP output. The complete Cookie is sent only to validated ac.nowcoder.com pages; the access-token host receives only csrf_token and NOWCODER* cookies, while question metadata and judge hosts receive no Cookie. Redirect targets are checked before a follow-up request receives authentication.
Security
- Local stdio transport only.
- Exact HTTPS host and path allowlists, public-IP DNS validation, and TLS address pinning.
- Shared 10-second request deadline, 2 MiB response limit, 16 KiB Cookie limit, and bounded redirects.
- Strict tool schemas with no Cookie field; redacted errors and authentication status.
- Cookie, CSRF token, and short-lived judge token never enter MCP output, MCP errors, process logs, or submission previews.
- Judge actions re-read a saved local
file:URI before confirmation and again before upload; dirty, changed, or mislabeled artifacts are rejected. - Every real submission requires a fresh confirmation; platform self-test also confirms before uploading code.
- Anti-bot challenges are surfaced as
challenge.requiredfor the user to complete in a browser.
Development
npm run typecheck:test --workspace @ketherworks/nowcoder-oj-mcp
npm test --workspace @ketherworks/nowcoder-oj-mcp
npm run pack:check --workspace @ketherworks/nowcoder-oj-mcp
Tests use synthetic sessions, static fixtures, and loopback-only TLS servers.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。