@pipeworx/mcp-codeforces 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Pipeworx
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,63 @@
1
+ # mcp-codeforces
2
+
3
+ Codeforces competitive programming users, contests, problems
4
+
5
+ Part of [Pipeworx](https://pipeworx.io) — an MCP gateway connecting AI agents to 250+ live data sources.
6
+
7
+ ## Tools
8
+
9
+ | Tool | Description |
10
+ |------|-------------|
11
+ | `user` | User profile(s) by handle (up to 10000 semicolon-separated). |
12
+ | `user_rating` | Full rating history for a user. |
13
+ | `user_status` | Recent submissions for a user. |
14
+ | `contest_list` | All contests. Pass gym=true for gym contests. |
15
+ | `contest_standings` | Standings (and problem list) for a contest. Optionally filter by handles. |
16
+ | `problemset` | Problemset + per-problem submission counts. Optional tag filter. |
17
+ | `recent_actions` | Recent global actions feed. |
18
+ | `blog_entry_view` | Full blog entry by id. |
19
+
20
+ ## Quick Start
21
+
22
+ Add to your MCP client (Claude Desktop, Cursor, Windsurf, etc.):
23
+
24
+ ```json
25
+ {
26
+ "mcpServers": {
27
+ "codeforces": {
28
+ "url": "https://gateway.pipeworx.io/codeforces/mcp"
29
+ }
30
+ }
31
+ }
32
+ ```
33
+
34
+ Or connect to the full Pipeworx gateway for access to all 250+ data sources:
35
+
36
+ ```json
37
+ {
38
+ "mcpServers": {
39
+ "pipeworx": {
40
+ "url": "https://gateway.pipeworx.io/mcp"
41
+ }
42
+ }
43
+ }
44
+ ```
45
+
46
+ ## Using with ask_pipeworx
47
+
48
+ Instead of calling tools directly, you can ask questions in plain English:
49
+
50
+ ```
51
+ ask_pipeworx({ question: "your question about Codeforces data" })
52
+ ```
53
+
54
+ The gateway picks the right tool and fills the arguments automatically.
55
+
56
+ ## More
57
+
58
+ - [All tools and guides](https://github.com/pipeworx-io/examples)
59
+ - [pipeworx.io](https://pipeworx.io)
60
+
61
+ ## License
62
+
63
+ MIT
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@pipeworx/mcp-codeforces",
3
+ "version": "0.1.0",
4
+ "description": "Codeforces competitive programming users, contests, problems",
5
+ "type": "module",
6
+ "main": "src/index.ts",
7
+ "types": "src/index.ts",
8
+ "keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "codeforces"],
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/pipeworx-io/mcp-codeforces"
13
+ },
14
+ "scripts": {
15
+ "typecheck": "tsc --noEmit"
16
+ },
17
+ "devDependencies": {
18
+ "typescript": "^5.7.0"
19
+ }
20
+ }
package/server.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
3
+ "name": "io.github.pipeworx-io/codeforces",
4
+ "title": "Codeforces",
5
+ "description": "Codeforces competitive programming users, contests, problems",
6
+ "version": "0.1.0",
7
+ "websiteUrl": "https://pipeworx.io/packs/codeforces",
8
+ "repository": {
9
+ "url": "https://github.com/pipeworx-io/mcp-codeforces",
10
+ "source": "github"
11
+ },
12
+ "remotes": [
13
+ {
14
+ "type": "streamable-http",
15
+ "url": "https://gateway.pipeworx.io/codeforces/mcp"
16
+ }
17
+ ]
18
+ }
package/src/index.ts ADDED
@@ -0,0 +1,188 @@
1
+ interface McpToolDefinition {
2
+ name: string;
3
+ description: string;
4
+ inputSchema: {
5
+ type: 'object';
6
+ properties: Record<string, unknown>;
7
+ required?: string[];
8
+ };
9
+ }
10
+
11
+ interface McpToolExport {
12
+ tools: McpToolDefinition[];
13
+ callTool: (name: string, args: Record<string, unknown>) => Promise<unknown>;
14
+ meter?: { credits: number };
15
+ cost?: Record<string, unknown>;
16
+ provider?: string;
17
+ }
18
+
19
+ /**
20
+ * Codeforces MCP — public read API.
21
+ *
22
+ * Auth: none for public endpoints. Docs: https://codeforces.com/apiHelp
23
+ */
24
+
25
+
26
+ const BASE = 'https://codeforces.com/api';
27
+ const UA = 'pipeworx-mcp-codeforces/1.0 (+https://pipeworx.io)';
28
+
29
+ const tools: McpToolExport['tools'] = [
30
+ {
31
+ name: 'user',
32
+ description: 'User profile(s) by handle (up to 10000 semicolon-separated).',
33
+ inputSchema: {
34
+ type: 'object',
35
+ properties: {
36
+ handles: { type: 'array', items: { type: 'string' }, description: '1-10000 handles' },
37
+ },
38
+ required: ['handles'],
39
+ },
40
+ },
41
+ {
42
+ name: 'user_rating',
43
+ description: 'Full rating history for a user.',
44
+ inputSchema: {
45
+ type: 'object',
46
+ properties: { handle: { type: 'string' } },
47
+ required: ['handle'],
48
+ },
49
+ },
50
+ {
51
+ name: 'user_status',
52
+ description: 'Recent submissions for a user.',
53
+ inputSchema: {
54
+ type: 'object',
55
+ properties: {
56
+ handle: { type: 'string' },
57
+ from: { type: 'number', description: '1-based start (default 1)' },
58
+ count: { type: 'number', description: '1-10000 (default 50)' },
59
+ },
60
+ required: ['handle'],
61
+ },
62
+ },
63
+ {
64
+ name: 'contest_list',
65
+ description: 'All contests. Pass gym=true for gym contests.',
66
+ inputSchema: {
67
+ type: 'object',
68
+ properties: { gym: { type: 'boolean' } },
69
+ },
70
+ },
71
+ {
72
+ name: 'contest_standings',
73
+ description: 'Standings (and problem list) for a contest. Optionally filter by handles.',
74
+ inputSchema: {
75
+ type: 'object',
76
+ properties: {
77
+ contest_id: { type: 'number' },
78
+ handles: { type: 'array', items: { type: 'string' } },
79
+ from: { type: 'number' },
80
+ count: { type: 'number', description: '1-1000 (default 100)' },
81
+ },
82
+ required: ['contest_id'],
83
+ },
84
+ },
85
+ {
86
+ name: 'problemset',
87
+ description: 'Problemset + per-problem submission counts. Optional tag filter.',
88
+ inputSchema: {
89
+ type: 'object',
90
+ properties: {
91
+ tags: { type: 'array', items: { type: 'string' }, description: 'e.g. ["dp","graphs"]' },
92
+ problemset_name: { type: 'string', description: 'Custom problemset (rarely used).' },
93
+ },
94
+ },
95
+ },
96
+ {
97
+ name: 'recent_actions',
98
+ description: 'Recent global actions feed.',
99
+ inputSchema: {
100
+ type: 'object',
101
+ properties: { max_count: { type: 'number', description: '1-100 (default 30)' } },
102
+ },
103
+ },
104
+ {
105
+ name: 'blog_entry_view',
106
+ description: 'Full blog entry by id.',
107
+ inputSchema: {
108
+ type: 'object',
109
+ properties: { blog_id: { type: 'number' } },
110
+ required: ['blog_id'],
111
+ },
112
+ },
113
+ ];
114
+
115
+ async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
116
+ switch (name) {
117
+ case 'user': {
118
+ const handles = reqArr(args, 'handles', '["tourist"]').slice(0, 10000).join(';');
119
+ return cfGet(`/user.info?handles=${encodeURIComponent(handles)}`);
120
+ }
121
+ case 'user_rating':
122
+ return cfGet(`/user.rating?handle=${encodeURIComponent(reqStr(args, 'handle', '"tourist"'))}`);
123
+ case 'user_status': {
124
+ const params = new URLSearchParams({
125
+ handle: reqStr(args, 'handle', '"tourist"'),
126
+ from: String(Math.max(1, (args.from as number) ?? 1)),
127
+ count: String(Math.min(10000, Math.max(1, (args.count as number) ?? 50))),
128
+ });
129
+ return cfGet(`/user.status?${params}`);
130
+ }
131
+ case 'contest_list': {
132
+ const gym = args.gym === true;
133
+ return cfGet(`/contest.list?gym=${gym ? 'true' : 'false'}`);
134
+ }
135
+ case 'contest_standings': {
136
+ const params = new URLSearchParams({
137
+ contestId: String((args.contest_id as number) | 0),
138
+ from: String(Math.max(1, (args.from as number) ?? 1)),
139
+ count: String(Math.min(1000, Math.max(1, (args.count as number) ?? 100))),
140
+ });
141
+ if (Array.isArray(args.handles) && args.handles.length > 0) {
142
+ params.set('handles', (args.handles as string[]).filter((s) => typeof s === 'string').join(';'));
143
+ }
144
+ return cfGet(`/contest.standings?${params}`);
145
+ }
146
+ case 'problemset': {
147
+ const params = new URLSearchParams();
148
+ if (Array.isArray(args.tags) && args.tags.length > 0) {
149
+ params.set('tags', (args.tags as string[]).filter((s) => typeof s === 'string').join(';'));
150
+ }
151
+ if (args.problemset_name) params.set('problemsetName', String(args.problemset_name));
152
+ const qs = params.toString();
153
+ return cfGet(`/problemset.problems${qs ? `?${qs}` : ''}`);
154
+ }
155
+ case 'recent_actions':
156
+ return cfGet(`/recentActions?maxCount=${Math.min(100, Math.max(1, (args.max_count as number) ?? 30))}`);
157
+ case 'blog_entry_view':
158
+ return cfGet(`/blogEntry.view?blogEntryId=${(args.blog_id as number) | 0}`);
159
+ default:
160
+ throw new Error(`Unknown tool: ${name}`);
161
+ }
162
+ }
163
+
164
+ async function cfGet(path: string): Promise<unknown> {
165
+ const res = await fetch(`${BASE}${path}`, { headers: { Accept: 'application/json', 'User-Agent': UA } });
166
+ if (!res.ok) throw new Error(`Codeforces: ${res.status} ${await res.text().then((t) => t.slice(0, 200))}`);
167
+ const json = (await res.json()) as { status?: string; comment?: string; result?: unknown };
168
+ if (json.status === 'FAILED') throw new Error(`Codeforces: ${json.comment ?? 'request failed'}`);
169
+ return json;
170
+ }
171
+
172
+ function reqStr(args: Record<string, unknown>, key: string, example: string): string {
173
+ const v = args[key];
174
+ if (typeof v !== 'string' || !v.trim()) {
175
+ throw new Error(`Required argument "${key}" is missing. Pass a string like ${example}.`);
176
+ }
177
+ return v;
178
+ }
179
+
180
+ function reqArr(args: Record<string, unknown>, key: string, example: string): string[] {
181
+ const v = args[key];
182
+ if (!Array.isArray(v) || v.length === 0) {
183
+ throw new Error(`Required argument "${key}" must be a non-empty array, e.g. ${example}.`);
184
+ }
185
+ return v.filter((s): s is string => typeof s === 'string');
186
+ }
187
+
188
+ export default { tools, callTool, meter: { credits: 1 } } satisfies McpToolExport;
package/tsconfig.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "strict": true,
7
+ "esModuleInterop": true,
8
+ "skipLibCheck": true,
9
+ "outDir": "dist",
10
+ "rootDir": "src",
11
+ "declaration": true
12
+ },
13
+ "include": ["src"]
14
+ }