@pipeworx/mcp-stratz 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,59 @@
1
+ # mcp-stratz
2
+
3
+ STRATZ Dota 2 MCP.
4
+
5
+ Part of [Pipeworx](https://pipeworx.io) — an MCP gateway connecting AI agents to 965+ live data sources.
6
+
7
+ ## Tools
8
+
9
+ | Tool | Description |
10
+ |------|-------------|
11
+ | `graphql` | Send an arbitrary GraphQL query (with optional variables) directly to the STRATZ API at api.stratz.com/graphql. Use when no named tool covers the data you need. Requires a STRATZ Bearer token. |
12
+ | `hero_stats` | Fetch daily win-rate and pick-rate statistics for a Dota 2 hero by numeric hero_id, optionally filtered to a rank bracket (e.g. HERALD, ARCHON, LEGEND, DIVINE, IMMORTAL). Returns matchCount and winCount per day. |
13
+ | `player_matches` | Fetch a Dota 2 player's recent match history by Steam account id. Returns match id, duration, start time, Radiant win flag, heroId and K/D/A. Supports pagination via take/skip. |
14
+ | `player_heroes` | Fetch the top heroes played by a Dota 2 player (by Steam account id), ranked by match count — returns heroId, matchCount, and winCount for up to `take` heroes (default 20). |
15
+
16
+ ## Quick Start
17
+
18
+ Add to your MCP client (Claude Desktop, Cursor, Windsurf, etc.):
19
+
20
+ ```json
21
+ {
22
+ "mcpServers": {
23
+ "stratz": {
24
+ "url": "https://gateway.pipeworx.io/stratz/mcp"
25
+ }
26
+ }
27
+ }
28
+ ```
29
+
30
+ Or connect to the full Pipeworx gateway for access to all 965+ data sources:
31
+
32
+ ```json
33
+ {
34
+ "mcpServers": {
35
+ "pipeworx": {
36
+ "url": "https://gateway.pipeworx.io/mcp"
37
+ }
38
+ }
39
+ }
40
+ ```
41
+
42
+ ## Using with ask_pipeworx
43
+
44
+ Instead of calling tools directly, you can ask questions in plain English:
45
+
46
+ ```
47
+ ask_pipeworx({ question: "your question about Stratz data" })
48
+ ```
49
+
50
+ The gateway picks the right tool and fills the arguments automatically.
51
+
52
+ ## More
53
+
54
+ - [All tools and guides](https://github.com/pipeworx-io/examples)
55
+ - [pipeworx.io](https://pipeworx.io)
56
+
57
+ ## License
58
+
59
+ MIT
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@pipeworx/mcp-stratz",
3
+ "version": "0.1.0",
4
+ "description": "STRATZ Dota 2 MCP.",
5
+ "type": "module",
6
+ "main": "src/index.ts",
7
+ "types": "src/index.ts",
8
+ "keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "stratz"],
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/pipeworx-io/mcp-stratz"
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/stratz",
4
+ "title": "Stratz",
5
+ "description": "STRATZ Dota 2 MCP.",
6
+ "version": "0.1.0",
7
+ "websiteUrl": "https://pipeworx.io/packs/stratz",
8
+ "repository": {
9
+ "url": "https://github.com/pipeworx-io/mcp-stratz",
10
+ "source": "github"
11
+ },
12
+ "remotes": [
13
+ {
14
+ "type": "streamable-http",
15
+ "url": "https://gateway.pipeworx.io/stratz/mcp"
16
+ }
17
+ ]
18
+ }
package/src/index.ts ADDED
@@ -0,0 +1,134 @@
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
+ * STRATZ Dota 2 MCP.
21
+ */
22
+
23
+
24
+ const ENDPOINT = 'https://api.stratz.com/graphql';
25
+ const UA = 'STRATZ_API pipeworx-mcp-stratz/1.0 (+https://pipeworx.io)';
26
+
27
+ const tools: McpToolExport['tools'] = [
28
+ {
29
+ name: 'graphql',
30
+ description: 'Send an arbitrary GraphQL query (with optional variables) directly to the STRATZ API at api.stratz.com/graphql. Use when no named tool covers the data you need. Requires a STRATZ Bearer token.',
31
+ inputSchema: { type: 'object', properties: { query: { type: 'string' }, variables: { type: 'object' } }, required: ['query'] },
32
+ },
33
+ { name: 'hero', description: 'Fetch a single Dota 2 hero\'s full detail by numeric hero id — display name, short name, roles, and base/gain stats (armor, strength, agility, intelligence, attack range, move speed, vision range).', inputSchema: { type: 'object', properties: { id: { type: 'number' } }, required: ['id'] } },
34
+ { name: 'heroes', description: 'Fetch the complete list of all Dota 2 heroes from STRATZ, returning each hero\'s numeric id, name, displayName, and shortName. No arguments required.', inputSchema: { type: 'object', properties: {} } },
35
+ {
36
+ name: 'hero_stats',
37
+ description: 'Fetch daily win-rate and pick-rate statistics for a Dota 2 hero by numeric hero_id, optionally filtered to a rank bracket (e.g. HERALD, ARCHON, LEGEND, DIVINE, IMMORTAL). Returns matchCount and winCount per day.',
38
+ inputSchema: { type: 'object', properties: { hero_id: { type: 'number' }, rank: { type: 'string' } }, required: ['hero_id'] },
39
+ },
40
+ { name: 'match', description: 'Fetch full details of a single Dota 2 match by numeric match id — duration, start time, Radiant/Dire teams, game mode, lobby type, and per-player stats (heroId, K/D/A, GPM, XPM, level).', inputSchema: { type: 'object', properties: { id: { type: 'number' } }, required: ['id'] } },
41
+ { name: 'player', description: 'Fetch a Dota 2 player\'s profile by Steam account id — Steam name, profile URL, avatar, total match count, and win count via STRATZ.', inputSchema: { type: 'object', properties: { steam_account_id: { type: 'number' } }, required: ['steam_account_id'] } },
42
+ {
43
+ name: 'player_matches',
44
+ description: "Fetch a Dota 2 player's recent match history by Steam account id. Returns match id, duration, start time, Radiant win flag, heroId and K/D/A. Supports pagination via take/skip.",
45
+ inputSchema: { type: 'object', properties: { steam_account_id: { type: 'number' }, take: { type: 'number' }, skip: { type: 'number' }, mode: { type: 'string' } }, required: ['steam_account_id'] },
46
+ },
47
+ {
48
+ name: 'player_heroes',
49
+ description: "Fetch the top heroes played by a Dota 2 player (by Steam account id), ranked by match count — returns heroId, matchCount, and winCount for up to `take` heroes (default 20).",
50
+ inputSchema: { type: 'object', properties: { steam_account_id: { type: 'number' }, take: { type: 'number' } }, required: ['steam_account_id'] },
51
+ },
52
+ { name: 'live_matches', description: 'Fetch all currently live Dota 2 matches from STRATZ, returning matchId, radiantTeamId, direTeamId, and current game time. No arguments required.', inputSchema: { type: 'object', properties: {} } },
53
+ { name: 'tournament', description: 'Fetch details for a single Dota 2 tournament (league) by numeric id — display name, description, tier, start/end dates, and prize pool.', inputSchema: { type: 'object', properties: { id: { type: 'number' } }, required: ['id'] } },
54
+ { name: 'tournaments', description: 'List Dota 2 tournaments from STRATZ ordered by start date (most recent first, up to 50). Pass only_premium=true to restrict to MAJOR and INTERNATIONAL tier events.', inputSchema: { type: 'object', properties: { only_premium: { type: 'boolean' } } } },
55
+ { name: 'meta', description: 'Fetch current Dota 2 meta constants from STRATZ: the list of game versions (patches) with their id and name. No arguments required.', inputSchema: { type: 'object', properties: {} } },
56
+ ];
57
+
58
+ async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
59
+ const apiKey = (args._apiKey as string | undefined)?.trim();
60
+ if (!apiKey) throw new Error('STRATZ requires an API token. Set PLATFORM_STRATZ_KEY or pass ?_apiKey=… (free at https://stratz.com/api).');
61
+ const headers = { Accept: 'application/json', 'Content-Type': 'application/json', 'User-Agent': UA, Authorization: `Bearer ${apiKey}` };
62
+ const gql = async (query: string, variables: Record<string, unknown> = {}) => {
63
+ const res = await fetch(ENDPOINT, { method: 'POST', headers, body: JSON.stringify({ query, variables }) });
64
+ if (res.status === 401 || res.status === 403) throw new Error('STRATZ: invalid API token.');
65
+ if (!res.ok) throw new Error(`STRATZ: ${res.status}`);
66
+ const j = (await res.json()) as { data?: unknown; errors?: unknown };
67
+ if (j.errors) throw new Error(`STRATZ GraphQL: ${JSON.stringify(j.errors)}`);
68
+ return j.data;
69
+ };
70
+ const reqNum = (k: string, ex: string) => {
71
+ const v = args[k];
72
+ if (v == null || typeof v !== 'number') throw new Error(`Required argument "${k}" is missing. Pass a number like ${ex}.`);
73
+ return v;
74
+ };
75
+ const reqStr = (k: string, ex: string) => {
76
+ const v = args[k];
77
+ if (typeof v !== 'string' || !v.trim()) throw new Error(`Required argument "${k}" is missing. Pass a string like ${ex}.`);
78
+ return v;
79
+ };
80
+ switch (name) {
81
+ case 'graphql':
82
+ return gql(reqStr('query', '"query { constants { gameMode { id name } } }"'), (args.variables as Record<string, unknown> | undefined) ?? {});
83
+ case 'hero':
84
+ return gql(
85
+ `query Hero($id: Short!) { constants { hero(id: $id) { id name displayName shortName roles { roleId } stats { startingArmor strengthBase strengthGain agilityBase agilityGain intelligenceBase intelligenceGain attackRange attackRate attackSpeed moveSpeed visionDaytimeRange visionNighttimeRange } } } }`,
86
+ { id: reqNum('id', '14') },
87
+ );
88
+ case 'heroes':
89
+ return gql(`query Heroes { constants { heroes { id name displayName shortName } } }`);
90
+ case 'hero_stats':
91
+ return gql(
92
+ `query HeroStats($id: Short!, $rank: [RankBracket!]) { heroStats { winDay(heroIds: [$id], bracketIds: $rank) { day matchCount winCount } } }`,
93
+ { id: reqNum('hero_id', '14'), rank: args.rank ? [String(args.rank)] : null },
94
+ );
95
+ case 'match':
96
+ return gql(
97
+ `query Match($id: Long!) { match(id: $id) { id durationSeconds startDateTime didRadiantWin gameMode lobbyType radiantTeam { id name } direTeam { id name } players { steamAccountId heroId isRadiant kills deaths assists numLastHits goldPerMinute experiencePerMinute level } } }`,
98
+ { id: reqNum('id', '7000000000') },
99
+ );
100
+ case 'player':
101
+ return gql(
102
+ `query Player($id: Long!) { player(steamAccountId: $id) { steamAccountId steamAccount { name profileUri avatar } matchCount winCount } }`,
103
+ { id: reqNum('steam_account_id', '101270074') },
104
+ );
105
+ case 'player_matches':
106
+ return gql(
107
+ `query Matches($id: Long!, $take: Int, $skip: Int) { player(steamAccountId: $id) { matches(request: { take: $take, skip: $skip }) { id durationSeconds startDateTime didRadiantWin heroId kills deaths assists } } }`,
108
+ { id: reqNum('steam_account_id', '101270074'), take: args.take ?? 10, skip: args.skip ?? 0 },
109
+ );
110
+ case 'player_heroes':
111
+ return gql(
112
+ `query Heroes($id: Long!, $take: Int) { player(steamAccountId: $id) { heroesPerformance(take: $take) { heroId matchCount winCount } } }`,
113
+ { id: reqNum('steam_account_id', '101270074'), take: args.take ?? 20 },
114
+ );
115
+ case 'live_matches':
116
+ return gql(`query Live { live { matches { matchId radiantTeamId direTeamId gameTime } } }`);
117
+ case 'tournament':
118
+ return gql(
119
+ `query Tournament($id: Int!) { league(id: $id) { id displayName description tier startDateTime endDateTime prizePool } }`,
120
+ { id: reqNum('id', '15728') },
121
+ );
122
+ case 'tournaments':
123
+ return gql(
124
+ `query Tournaments($premium: [LeagueTier!]) { leagues(request: { tiers: $premium, take: 50, orderBy: START_DATE_TIME_DESC }) { id displayName tier startDateTime endDateTime prizePool } }`,
125
+ { premium: args.only_premium ? ['MAJOR', 'INTERNATIONAL'] : null },
126
+ );
127
+ case 'meta':
128
+ return gql(`query Meta { constants { gameVersions { id name } } }`);
129
+ default:
130
+ throw new Error(`Unknown tool: ${name}`);
131
+ }
132
+ }
133
+
134
+ 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
+ }