@pipeworx/mcp-cricsheet 0.0.0-stage → 0.2.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 +21 -0
- package/README.md +212 -2
- package/bin/cli.js +61 -0
- package/lib/index.js +333 -0
- package/package.json +31 -4
- package/server.json +18 -0
- package/tools.json +182 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mojibake Inc.
|
|
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
CHANGED
|
@@ -1,3 +1,213 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @pipeworx/cricsheet
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Ball-by-ball cricket data collapsed to the questions people actually ask: a
|
|
4
|
+
match's result and scorecard, a player's career batting/bowling aggregates,
|
|
5
|
+
and a head-to-head record between two teams. Covers Test matches, One Day
|
|
6
|
+
Internationals, T20 Internationals, and the Indian Premier League. Fleet
|
|
7
|
+
#2975.
|
|
8
|
+
|
|
9
|
+
Part of [Pipeworx](https://pipeworx.io) — an MCP gateway connecting AI agents to 1856+ live data sources. This is an independent, unofficial integration — not affiliated with, endorsed by, or published by the upstream provider.
|
|
10
|
+
|
|
11
|
+
## Tools
|
|
12
|
+
|
|
13
|
+
- `cricsheet_match(match_id)` — one match's full result plus, for every
|
|
14
|
+
innings, the batting card (each batter's runs/balls/4s/6s/how out) and
|
|
15
|
+
bowling card (each bowler's overs/runs/wickets). Use
|
|
16
|
+
`cricsheet_find_matches` first to get a `match_id`.
|
|
17
|
+
- `cricsheet_player_stats(player, format?)` — a cricketer's career batting
|
|
18
|
+
and bowling aggregates (matches, runs, average, strike rate, 100s/50s;
|
|
19
|
+
wickets, bowling average, economy). `player` is matched case-insensitively
|
|
20
|
+
as a substring against the short-form names this pack stores (e.g. "Kohli"
|
|
21
|
+
for "V Kohli"); an ambiguous query returns a candidate list instead of
|
|
22
|
+
guessing. Optionally scope to one `format`.
|
|
23
|
+
- `cricsheet_head_to_head(team_a, team_b, format?, limit?, offset?)` — total
|
|
24
|
+
matches, each team's wins, ties/no-results, and the most recent matches
|
|
25
|
+
with their results. Team names must match Cricsheet's own strings (e.g.
|
|
26
|
+
`"India"`, `"Mumbai Indians"`).
|
|
27
|
+
- `cricsheet_find_matches(team?, format?, season?, venue?, player?, limit?, offset?)`
|
|
28
|
+
— search the match index to discover `match_id`s. With no filters, returns
|
|
29
|
+
the most recent matches held across every format.
|
|
30
|
+
- `cricsheet_chase_search(second_innings_result?, format?, min/max_wickets_remaining?, min/max_balls_remaining?, team?, gender?, season?, event?, date_from?, date_to?, limit?, offset?)`
|
|
31
|
+
— compound search on the chase (second innings) in ODI, T20I and IPL
|
|
32
|
+
matches: did the side batting second win, how many wickets in hand and
|
|
33
|
+
balls unused at the end, by date, season and tournament. `balls_remaining`
|
|
34
|
+
assumes the full scheduled overs (120 T20, 300 ODI) and is null for matches
|
|
35
|
+
decided by a rain method. Tests are excluded.
|
|
36
|
+
|
|
37
|
+
`format` accepts `"Test"`, `"ODI"`, `"T20I"` (international T20), or `"IPL"`
|
|
38
|
+
(case-insensitive); omit it to search across all four.
|
|
39
|
+
|
|
40
|
+
**What this pack does not do:** it does not return individual deliveries
|
|
41
|
+
(ball-by-ball). Every match file is parsed ball-by-ball once, at load time,
|
|
42
|
+
and collapsed into match / innings / batting-card / bowling-card rows —
|
|
43
|
+
storing every ball for ~11,000 matches would multiply the row count by
|
|
44
|
+
roughly 150-200x for a question ("who scored what, who took which wickets")
|
|
45
|
+
that the scorecard already answers.
|
|
46
|
+
|
|
47
|
+
## Auth
|
|
48
|
+
|
|
49
|
+
Keyless. The tools answer only through the Pipeworx gateway, which holds the
|
|
50
|
+
data; a standalone `npm install` has no data to read, and every tool throws
|
|
51
|
+
a clear "not bound in this runtime" error there instead of returning an
|
|
52
|
+
empty list.
|
|
53
|
+
|
|
54
|
+
## Data sources
|
|
55
|
+
|
|
56
|
+
- Cricsheet — ball-by-ball match data for Test cricket, One Day
|
|
57
|
+
Internationals, T20 Internationals, and the Indian Premier League.
|
|
58
|
+
**Licence: ODC Attribution License (ODC-BY)** — free to share, adapt and
|
|
59
|
+
use (including commercially) with attribution to Cricsheet. Cricsheet
|
|
60
|
+
publishes bulk per-match files only (no live API), so this pack builds a
|
|
61
|
+
copy (`scripts/cricsheet/load-data.mjs`) into a D1 database rather than
|
|
62
|
+
proxying per request, per CLAUDE.md's "build the copy" rule for a
|
|
63
|
+
bulk-only source.
|
|
64
|
+
|
|
65
|
+
### Known gaps — read before extending this pack
|
|
66
|
+
|
|
67
|
+
**Only four of Cricsheet's ~60 competitions are loaded.** Cricsheet also
|
|
68
|
+
publishes first-class, List A, and ~50 domestic T20 leagues (Big Bash, T20
|
|
69
|
+
Blast, Pakistan Super League, Caribbean Premier League, The Hundred, and so
|
|
70
|
+
on) as separate bulk files. This pack loads the four with the clearest
|
|
71
|
+
cross-format demand (international Test/ODI/T20I plus the IPL, the league
|
|
72
|
+
named explicitly in the originating demand signal). Adding another league is
|
|
73
|
+
one more entry in `BULK_FILES` in the loader, using the same
|
|
74
|
+
match-type-agnostic parser.
|
|
75
|
+
|
|
76
|
+
**Women's matches are included wherever Cricsheet's own bulk file includes
|
|
77
|
+
them**, distinguished by the `gender` field Cricsheet carries per match — not
|
|
78
|
+
filtered out, not separately tooled.
|
|
79
|
+
|
|
80
|
+
**Player identity is the raw name string Cricsheet uses** (e.g. "V Kohli",
|
|
81
|
+
"SR Watson") — short forms, not full names, and this pack does not maintain
|
|
82
|
+
its own name-to-person mapping beyond what `cricsheet_player_stats`'s
|
|
83
|
+
substring match provides. Two different people sharing a short-form name
|
|
84
|
+
(rare, but not impossible across ~8,400 distinct names) would merge under
|
|
85
|
+
that string; nothing in Cricsheet's own files beyond the registry ID (not
|
|
86
|
+
currently loaded) resolves that.
|
|
87
|
+
|
|
88
|
+
**Super overs are stored as extra innings entries**, exactly as Cricsheet's
|
|
89
|
+
own `innings` array represents them (a tied T20 can have 3 or 4 innings
|
|
90
|
+
entries) — `cricsheet_match` returns whatever innings Cricsheet's file has,
|
|
91
|
+
including super-over ones.
|
|
92
|
+
|
|
93
|
+
### Refreshing or extending the data
|
|
94
|
+
|
|
95
|
+
Re-run `node scripts/cricsheet/load-data.mjs` (needs `wrangler` logged in to
|
|
96
|
+
the Pipeworx Cloudflare account, and `CLOUDFLARE_ACCOUNT_ID` set when more
|
|
97
|
+
than one account is visible) — it re-fetches every format live and replaces
|
|
98
|
+
every table (DROP + reload), because Cricsheet corrects historical files
|
|
99
|
+
rather than versioning them. `--only <Test|ODI|T20I|IPL>` reloads a single
|
|
100
|
+
format; `--dry-run` parses and prints counts without touching D1, useful
|
|
101
|
+
after changing the parser. Cricsheet adds new matches continuously (for
|
|
102
|
+
international and IPL cricket, typically within a day of the match); re-run
|
|
103
|
+
the loader periodically to pick those up — `data_as_of` in every tool
|
|
104
|
+
response names the load it is reading.
|
|
105
|
+
|
|
106
|
+
## Quick Start
|
|
107
|
+
|
|
108
|
+
Add to your MCP client (Claude Desktop, Cursor, Windsurf, etc.):
|
|
109
|
+
|
|
110
|
+
```json
|
|
111
|
+
{
|
|
112
|
+
"mcpServers": {
|
|
113
|
+
"cricsheet": {
|
|
114
|
+
"url": "https://gateway.pipeworx.io/cricsheet/mcp"
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### What this endpoint actually serves
|
|
121
|
+
|
|
122
|
+
`tools/list` at `https://gateway.pipeworx.io/cricsheet/mcp` returns the tools in the table
|
|
123
|
+
above **plus the shared Pipeworx meta-tools** — `ask_pipeworx`,
|
|
124
|
+
`discover_tools`, `search_within`, `remember`/`recall` and the rest of the
|
|
125
|
+
gateway-wide set. So the tool count you see is larger than this table: a
|
|
126
|
+
single-pack endpoint currently lists roughly 30 shared tools alongside the
|
|
127
|
+
pack's own. The connection's `initialize` response states its exact scope, and
|
|
128
|
+
is the authoritative answer for a given day.
|
|
129
|
+
|
|
130
|
+
This is deliberate, not multiplexing by accident. The meta-tools are what let a
|
|
131
|
+
scoped connection answer a question this pack does not cover — via
|
|
132
|
+
`ask_pipeworx`, which routes across the whole catalog — without you adding a
|
|
133
|
+
second MCP server. There is currently no way to mount a pack endpoint without
|
|
134
|
+
them; if the extra schemas cost you more context than the routing is worth,
|
|
135
|
+
connect to the full gateway once rather than to several pack endpoints.
|
|
136
|
+
|
|
137
|
+
Or connect to the full Pipeworx gateway to get every pack's tools listed
|
|
138
|
+
directly, instead of just this one's:
|
|
139
|
+
|
|
140
|
+
```json
|
|
141
|
+
{
|
|
142
|
+
"mcpServers": {
|
|
143
|
+
"pipeworx": {
|
|
144
|
+
"url": "https://gateway.pipeworx.io/mcp"
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Both URLs reach the same gateway and the same 1856+ data sources. The
|
|
151
|
+
only difference is which pack's tools are listed **directly**; `ask_pipeworx`
|
|
152
|
+
reaches all of them from either one.
|
|
153
|
+
|
|
154
|
+
## No MCP client? Call it over HTTP
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
curl -X POST https://gateway.pipeworx.io/v1/tools/cricsheet_match \
|
|
158
|
+
-H 'Content-Type: application/json' \
|
|
159
|
+
-d '{"match_id":1082591}'
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
No account needed for the first calls. Inspect any tool: `GET https://gateway.pipeworx.io/v1/tools/cricsheet_match`. Find one: `POST https://gateway.pipeworx.io/v1/tools/search_packs` with `{"query":"..."}`.
|
|
163
|
+
|
|
164
|
+
## Run it from npm
|
|
165
|
+
|
|
166
|
+
`@pipeworx/mcp-cricsheet` is a local stdio bridge to the Pipeworx gateway: your MCP client
|
|
167
|
+
starts it with `npx`, and it forwards every call to the same
|
|
168
|
+
`https://gateway.pipeworx.io/cricsheet/mcp` endpoint shown above. It needs network access;
|
|
169
|
+
there is no offline mode.
|
|
170
|
+
|
|
171
|
+
```json
|
|
172
|
+
{
|
|
173
|
+
"mcpServers": {
|
|
174
|
+
"cricsheet": {
|
|
175
|
+
"command": "npx",
|
|
176
|
+
"args": ["-y", "@pipeworx/mcp-cricsheet"]
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Without a key it calls anonymously, capped at 50 calls a day. A free account
|
|
183
|
+
raises that to 200 a day: get a key at https://pipeworx.io/signup and add
|
|
184
|
+
`"env": { "PIPEWORX_API_KEY": "<your key>" }` to the server entry.
|
|
185
|
+
The key is sent as a Bearer token, the same way a hosted connection sends it,
|
|
186
|
+
so calls are metered and billed exactly as they are there.
|
|
187
|
+
|
|
188
|
+
It lists **only** this pack's tools by default. Set `PIPEWORX_META_TOOLS=1` to
|
|
189
|
+
also list `ask_pipeworx` and the other gateway-wide tools.
|
|
190
|
+
|
|
191
|
+
Behind an HTTPS proxy: Node's built-in `fetch` does not read `HTTPS_PROXY` by
|
|
192
|
+
default. Newer Node releases honour it when `NODE_USE_ENV_PROXY=1` is set; check
|
|
193
|
+
your Node version's documentation.
|
|
194
|
+
|
|
195
|
+
## Using with ask_pipeworx
|
|
196
|
+
|
|
197
|
+
Instead of calling tools directly, you can ask questions in plain English —
|
|
198
|
+
this works on the pack endpoint above as well as on the full gateway:
|
|
199
|
+
|
|
200
|
+
```
|
|
201
|
+
ask_pipeworx({ question: "your question about Cricsheet data" })
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
The gateway picks the right tool and fills the arguments automatically.
|
|
205
|
+
|
|
206
|
+
## More
|
|
207
|
+
|
|
208
|
+
- [Docs and guides](https://pipeworx.io/docs)
|
|
209
|
+
- [pipeworx.io](https://pipeworx.io)
|
|
210
|
+
|
|
211
|
+
## License
|
|
212
|
+
|
|
213
|
+
MIT
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Entry point for `npx @pipeworx/mcp-<slug>` in gateway mode (bin/cli.js).
|
|
3
|
+
//
|
|
4
|
+
// A stdio MCP server that relays every message to the Pipeworx gateway's
|
|
5
|
+
// /<slug>/mcp endpoint -- fleet #3759, docs/standalone-via-gateway-plan.md.
|
|
6
|
+
// It carries no pack code and has no local mode. The relay itself lives in
|
|
7
|
+
// ../lib/index.js (copied from scripts/templates/standalone-gateway-lib.js);
|
|
8
|
+
// this file only owns stdin/stdout.
|
|
9
|
+
//
|
|
10
|
+
// Copied VERBATIM into every gateway-mode package by scripts/publish-pack.sh.
|
|
11
|
+
// Edit scripts/templates/standalone-gateway-cli.js in the monorepo, never a
|
|
12
|
+
// per-pack copy. Zero dependencies, Node 18+.
|
|
13
|
+
//
|
|
14
|
+
// stdout carries newline-delimited JSON-RPC and nothing else; every diagnostic
|
|
15
|
+
// goes to stderr, because a single stray line on stdout breaks the host's
|
|
16
|
+
// parser.
|
|
17
|
+
import { createInterface } from 'node:readline';
|
|
18
|
+
import { relay, bridgeConfig } from '../lib/index.js';
|
|
19
|
+
|
|
20
|
+
const cfg = bridgeConfig();
|
|
21
|
+
const warn = (line) => process.stderr.write(`${line}\n`);
|
|
22
|
+
const write = (msg) => { if (msg) process.stdout.write(`${JSON.stringify(msg)}\n`); };
|
|
23
|
+
|
|
24
|
+
const pending = new Set();
|
|
25
|
+
function track(p) {
|
|
26
|
+
pending.add(p);
|
|
27
|
+
p.finally(() => pending.delete(p));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async function handleLine(line) {
|
|
31
|
+
const text = line.trim();
|
|
32
|
+
if (!text) return;
|
|
33
|
+
let message;
|
|
34
|
+
try {
|
|
35
|
+
message = JSON.parse(text);
|
|
36
|
+
} catch {
|
|
37
|
+
write({ jsonrpc: '2.0', id: null, error: { code: -32700, message: 'Parse error' } });
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
// A JSON-RPC batch: relay each member, answer with the non-notification replies.
|
|
41
|
+
if (Array.isArray(message)) {
|
|
42
|
+
const replies = (await Promise.all(message.map((m) => relay(m, { cfg, warn })))).filter(Boolean);
|
|
43
|
+
if (replies.length) write(replies);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
write(await relay(message, { cfg, warn }));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Requests are handled concurrently and answered as they finish: JSON-RPC ids
|
|
50
|
+
// let the host match them, and a slow tool call must not hold up a ping.
|
|
51
|
+
const rl = createInterface({ input: process.stdin, crlfDelay: Infinity });
|
|
52
|
+
rl.on('line', (line) => {
|
|
53
|
+
track(handleLine(line).catch((err) => warn(`pipeworx-standalone: ${err && err.stack ? err.stack : err}`)));
|
|
54
|
+
});
|
|
55
|
+
rl.on('close', async () => {
|
|
56
|
+
// stdin closed: finish what is in flight, then exit.
|
|
57
|
+
while (pending.size) await Promise.allSettled([...pending]);
|
|
58
|
+
// Exit only once stdout has flushed: on a pipe that is not synchronous
|
|
59
|
+
// everywhere, and a bare exit can drop the last reply.
|
|
60
|
+
process.stdout.write('', () => process.exit(0));
|
|
61
|
+
});
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
// @pipeworx/mcp-<slug> -- library half of the gateway bridge (lib/index.js).
|
|
2
|
+
//
|
|
3
|
+
// Copied VERBATIM into every gateway-mode pack package by scripts/publish-pack.sh
|
|
4
|
+
// (fleet #3759, docs/standalone-via-gateway-plan.md section 1). There is no
|
|
5
|
+
// per-pack templating: the slug and version are read from this package's own
|
|
6
|
+
// package.json (`pipeworx.slug`, `version`) at load time, so the same bytes
|
|
7
|
+
// ship in every package and the source hash can cover them once. Edit this
|
|
8
|
+
// file in the monorepo (scripts/templates/standalone-gateway-lib.js), never a
|
|
9
|
+
// per-pack copy.
|
|
10
|
+
//
|
|
11
|
+
// What it is: a relay. Every JSON-RPC message goes to
|
|
12
|
+
// ${PIPEWORX_GATEWAY_URL:-https://gateway.pipeworx.io}/<slug>/mcp, the same
|
|
13
|
+
// endpoint a hosted MCP client uses, so tiers, rate limits and credits apply
|
|
14
|
+
// exactly as they do there. There is no local mode: the pack's code is not in
|
|
15
|
+
// this package.
|
|
16
|
+
//
|
|
17
|
+
// Zero dependencies, plain ESM, Node 18+ (global fetch). Nothing here writes
|
|
18
|
+
// to stdout -- bin/cli.js owns stdout and it carries JSON-RPC only.
|
|
19
|
+
//
|
|
20
|
+
// Environment:
|
|
21
|
+
// PIPEWORX_API_KEY sent as `Authorization: Bearer <key>`. Never as
|
|
22
|
+
// X-API-Key: the gateway reads a pwx_ key sent that way
|
|
23
|
+
// as an unvalidated BYO string with no account.
|
|
24
|
+
// PIPEWORX_GATEWAY_URL gateway base URL (no path), default the public gateway.
|
|
25
|
+
// PIPEWORX_META_TOOLS=1 list the gateway-wide tools (ask_pipeworx, ...) too.
|
|
26
|
+
// PIPEWORX_TIMEOUT_MS per-request timeout, default 120000.
|
|
27
|
+
|
|
28
|
+
import { readFileSync } from 'node:fs';
|
|
29
|
+
|
|
30
|
+
const readJson = (rel) => JSON.parse(readFileSync(new URL(rel, import.meta.url), 'utf8'));
|
|
31
|
+
|
|
32
|
+
const PKG = readJson('../package.json');
|
|
33
|
+
export const SLUG = PKG.pipeworx && PKG.pipeworx.slug;
|
|
34
|
+
if (typeof SLUG !== 'string' || !/^[a-z0-9][a-z0-9_-]*$/.test(SLUG)) {
|
|
35
|
+
throw new Error(`${PKG.name}: package.json carries no valid pipeworx.slug -- this package was built wrong`);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The pack's slug on the GATEWAY: the /<slug>/mcp route and the `_meta.pack`
|
|
39
|
+
* every listed tool carries. Usually the same as `slug` (the npm/directory
|
|
40
|
+
* name), but 14 packs differ -- `hex-pm` is `hex_pm` on the gateway -- and
|
|
41
|
+
* filtering tools/list on the npm slug would match none of their tools
|
|
42
|
+
* (fleet #3761). publish-pack.sh stamps it from the gateway manifest.
|
|
43
|
+
*/
|
|
44
|
+
export const GATEWAY_SLUG = (PKG.pipeworx && PKG.pipeworx.gatewaySlug) || SLUG;
|
|
45
|
+
if (typeof GATEWAY_SLUG !== 'string' || !/^[a-z0-9][a-z0-9_-]*$/.test(GATEWAY_SLUG)) {
|
|
46
|
+
throw new Error(`${PKG.name}: package.json carries an invalid pipeworx.gatewaySlug -- this package was built wrong`);
|
|
47
|
+
}
|
|
48
|
+
export const PACKAGE_NAME = PKG.name;
|
|
49
|
+
export const VERSION = PKG.version;
|
|
50
|
+
|
|
51
|
+
/** The pack's own tool definitions at publish time (the offline tools/list answer). */
|
|
52
|
+
export const tools = readJson('../tools.json');
|
|
53
|
+
|
|
54
|
+
const DEFAULT_GATEWAY = 'https://gateway.pipeworx.io';
|
|
55
|
+
const DEFAULT_TIMEOUT_MS = 120_000;
|
|
56
|
+
const SIGNUP_URL = 'https://pipeworx.io/signup';
|
|
57
|
+
const VIA = '(via pipeworx-standalone)';
|
|
58
|
+
|
|
59
|
+
/** Resolve the bridge's settings. Exported for the tests and for callTool. */
|
|
60
|
+
export function bridgeConfig(env = process.env, overrides = {}) {
|
|
61
|
+
const base = String(overrides.gatewayUrl || env.PIPEWORX_GATEWAY_URL || DEFAULT_GATEWAY).trim().replace(/\/+$/, '');
|
|
62
|
+
const apiKey = String(overrides.apiKey ?? env.PIPEWORX_API_KEY ?? '').trim();
|
|
63
|
+
const t = Number(overrides.timeoutMs ?? env.PIPEWORX_TIMEOUT_MS);
|
|
64
|
+
return {
|
|
65
|
+
endpoint: `${base}/${GATEWAY_SLUG}/mcp`,
|
|
66
|
+
apiKey,
|
|
67
|
+
timeoutMs: Number.isFinite(t) && t > 0 ? t : DEFAULT_TIMEOUT_MS,
|
|
68
|
+
metaTools: (overrides.metaTools ?? env.PIPEWORX_META_TOOLS) === '1' || overrides.metaTools === true,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function requestHeaders(cfg) {
|
|
73
|
+
const h = {
|
|
74
|
+
'Content-Type': 'application/json',
|
|
75
|
+
Accept: 'application/json',
|
|
76
|
+
// Stable per package version: the gateway remembers a client's name by
|
|
77
|
+
// identifier + User-Agent (workers/gateway/src/client-identity.ts).
|
|
78
|
+
'User-Agent': `pipeworx-standalone/${VERSION} (${PACKAGE_NAME})`,
|
|
79
|
+
// Analytics label only (blob11 = 'standalone'). It never changes tier,
|
|
80
|
+
// limits or price -- anyone can send it.
|
|
81
|
+
'X-Pipeworx-Surface': 'standalone',
|
|
82
|
+
};
|
|
83
|
+
if (cfg.apiKey) h.Authorization = `Bearer ${cfg.apiKey}`;
|
|
84
|
+
return h;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** Parse a gateway body: JSON, or the last JSON `data:` frame of an SSE stream. */
|
|
88
|
+
function parseBody(text, contentType) {
|
|
89
|
+
if (/text\/event-stream/i.test(contentType || '')) {
|
|
90
|
+
let last = null;
|
|
91
|
+
for (const line of text.split(/\r?\n/)) {
|
|
92
|
+
if (!line.startsWith('data:')) continue;
|
|
93
|
+
try { last = JSON.parse(line.slice(5).trim()); } catch { /* keep-alive or partial frame */ }
|
|
94
|
+
}
|
|
95
|
+
return last;
|
|
96
|
+
}
|
|
97
|
+
try { return JSON.parse(text); } catch { return null; }
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* POST one JSON-RPC message. Never throws: the outcome is one of
|
|
102
|
+
* { kind: 'http', status, headers, body, text } the gateway answered
|
|
103
|
+
* { kind: 'network', detail } DNS, TLS, refused, reset
|
|
104
|
+
* { kind: 'timeout' } no answer in cfg.timeoutMs
|
|
105
|
+
*/
|
|
106
|
+
export async function postToGateway(message, cfg) {
|
|
107
|
+
const ac = new AbortController();
|
|
108
|
+
const timer = setTimeout(() => ac.abort(), cfg.timeoutMs);
|
|
109
|
+
try {
|
|
110
|
+
const res = await fetch(cfg.endpoint, {
|
|
111
|
+
method: 'POST',
|
|
112
|
+
headers: requestHeaders(cfg),
|
|
113
|
+
body: JSON.stringify(message),
|
|
114
|
+
signal: ac.signal,
|
|
115
|
+
});
|
|
116
|
+
const text = await res.text();
|
|
117
|
+
return { kind: 'http', status: res.status, headers: res.headers, body: parseBody(text, res.headers.get('content-type')), text };
|
|
118
|
+
} catch (err) {
|
|
119
|
+
if (ac.signal.aborted || (err && (err.name === 'AbortError' || err.name === 'TimeoutError'))) return { kind: 'timeout' };
|
|
120
|
+
const cause = err && err.cause;
|
|
121
|
+
const detail = (cause && (cause.code || cause.message)) || (err && err.message) || String(err);
|
|
122
|
+
return { kind: 'network', detail };
|
|
123
|
+
} finally {
|
|
124
|
+
clearTimeout(timer);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// ── The key-not-accepted warning (one per process) ──────────────────
|
|
129
|
+
|
|
130
|
+
let warnedKeyIgnored = false;
|
|
131
|
+
const KEY_IGNORED = 'PIPEWORX_API_KEY was not accepted, calling anonymously.';
|
|
132
|
+
|
|
133
|
+
/** True when a key was sent but the gateway still served the call as anonymous. */
|
|
134
|
+
function keyIgnored(out, cfg) {
|
|
135
|
+
return !!cfg.apiKey && out.kind === 'http' && (out.headers.get('x-ratelimit-tier') || '').toLowerCase() === 'anonymous';
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function noteTier(out, cfg, warn) {
|
|
139
|
+
if (!keyIgnored(out, cfg) || warnedKeyIgnored) return;
|
|
140
|
+
warnedKeyIgnored = true;
|
|
141
|
+
warn(`${PACKAGE_NAME}: ${KEY_IGNORED} Check the key at ${SIGNUP_URL}.`);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** Test hook: forget that the warning was printed. */
|
|
145
|
+
export function _resetWarnings() { warnedKeyIgnored = false; }
|
|
146
|
+
|
|
147
|
+
// ── Results the host shows to the model ─────────────────────────────
|
|
148
|
+
|
|
149
|
+
function errorResult(text, detail) {
|
|
150
|
+
const result = { content: [{ type: 'text', text }], isError: true };
|
|
151
|
+
if (detail) result._meta = { pipeworx_standalone: detail };
|
|
152
|
+
return result;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const rpcResult = (id, result) => ({ jsonrpc: '2.0', id, result });
|
|
156
|
+
const rpcError = (id, code, message) => ({ jsonrpc: '2.0', id, error: { code, message } });
|
|
157
|
+
|
|
158
|
+
function firstLine(text) {
|
|
159
|
+
const line = String(text || '').split(/\r?\n/).map((l) => l.trim()).find(Boolean) || '(empty body)';
|
|
160
|
+
return line.length > 200 ? `${line.slice(0, 200)}...` : line;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function unreachableText(cfg, out) {
|
|
164
|
+
if (out.kind === 'timeout') {
|
|
165
|
+
return `The Pipeworx gateway at ${cfg.endpoint} did not answer within ${Math.round(cfg.timeoutMs / 1000)}s, so this call timed out. `
|
|
166
|
+
+ `${PACKAGE_NAME} forwards every call to the Pipeworx gateway and has no local mode. Try again; a call that keeps timing out is worth reporting.`;
|
|
167
|
+
}
|
|
168
|
+
return `Could not reach the Pipeworx gateway at ${cfg.endpoint} (${out.detail}). `
|
|
169
|
+
+ `${PACKAGE_NAME} forwards every call to the Pipeworx gateway and has no local mode, so it needs network access.`;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function isAuthRequired(body) {
|
|
173
|
+
return !!body && (body.error_code === 'authentication_required'
|
|
174
|
+
|| (body.error && body.error.data && body.error.data.reason === 'authentication_required'));
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** Map a tools/call outcome to the JSON-RPC response the host gets. */
|
|
178
|
+
function toolsCallResponse(id, out, cfg) {
|
|
179
|
+
if (out.kind !== 'http') return rpcResult(id, errorResult(unreachableText(cfg, out), { reason: out.kind }));
|
|
180
|
+
const { status, body } = out;
|
|
181
|
+
|
|
182
|
+
// Anonymous daily cap: the gateway answers 401 with a JSON-RPC error whose
|
|
183
|
+
// message is the offer. Hosts often swallow protocol errors, so hand it over
|
|
184
|
+
// as a tool result the model actually reads.
|
|
185
|
+
if (status === 401 && isAuthRequired(body)) {
|
|
186
|
+
const data = (body.error && body.error.data) || {};
|
|
187
|
+
const parts = [body.error && body.error.message ? body.error.message : 'The anonymous daily allowance is used up.'];
|
|
188
|
+
if (data.resets_at) parts.push(`The anonymous allowance resets at ${data.resets_at}.`);
|
|
189
|
+
parts.push(cfg.apiKey
|
|
190
|
+
? `${KEY_IGNORED} Check the key, or get a free one at ${SIGNUP_URL}.`
|
|
191
|
+
: `To keep going now, set PIPEWORX_API_KEY in this MCP server's environment; a free key is at ${SIGNUP_URL}.`);
|
|
192
|
+
return rpcResult(id, errorResult(parts.join('\n\n'), { status, reason: 'authentication_required', resets_at: data.resets_at ?? null }));
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// A keyed tier over its cap: today the gateway answers 429 with a RESULT
|
|
196
|
+
// that has no isError, which reads as a success (fleet #3760). Mark it.
|
|
197
|
+
if (status === 429 && body && body.result && typeof body.result === 'object') {
|
|
198
|
+
const result = { ...body.result, isError: true };
|
|
199
|
+
if (cfg.apiKey && keyIgnored(out, cfg)) {
|
|
200
|
+
result.content = [...(Array.isArray(result.content) ? result.content : []), { type: 'text', text: KEY_IGNORED }];
|
|
201
|
+
}
|
|
202
|
+
return rpcResult(id, result);
|
|
203
|
+
}
|
|
204
|
+
if ((status === 401 || status === 429) && body && body.error) {
|
|
205
|
+
const extra = keyIgnored(out, cfg) ? ` ${KEY_IGNORED}` : '';
|
|
206
|
+
return rpcResult(id, errorResult(`${body.error.message || `HTTP ${status}`}${extra}`, { status }));
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// A real JSON-RPC answer (result or protocol error): relay it verbatim,
|
|
210
|
+
// structuredContent and _meta (cost, tier, provenance) included.
|
|
211
|
+
if (body && body.jsonrpc === '2.0' && (body.result !== undefined || body.error !== undefined) && status < 500) {
|
|
212
|
+
return { ...body, id };
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// 5xx, an HTML edge page, or anything else that is not JSON-RPC.
|
|
216
|
+
return rpcResult(id, errorResult(`The Pipeworx gateway returned HTTP ${status}: ${firstLine(out.text)}`, { status }));
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function localInitialize(params) {
|
|
220
|
+
return {
|
|
221
|
+
protocolVersion: (params && params.protocolVersion) || '2025-06-18',
|
|
222
|
+
capabilities: { tools: {} },
|
|
223
|
+
serverInfo: { name: PACKAGE_NAME, version: VERSION },
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const scopedInstructions = () =>
|
|
228
|
+
`${PACKAGE_NAME} forwards to the Pipeworx gateway and lists only the ${SLUG} pack's tools. `
|
|
229
|
+
+ 'Set PIPEWORX_META_TOOLS=1 to also list ask_pipeworx and the other gateway-wide tools.';
|
|
230
|
+
|
|
231
|
+
/** `<host name> (via pipeworx-standalone)`. The slug stays OUT of the name: the
|
|
232
|
+
* gateway's scanner-name check substring-matches words like poll/watch/index. */
|
|
233
|
+
export function bridgedClientName(name) {
|
|
234
|
+
const n = typeof name === 'string' && name.trim() ? name.trim() : 'unknown';
|
|
235
|
+
return n.includes(VIA) ? n : `${n} ${VIA}`;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Relay one JSON-RPC message to the gateway and return the response to write
|
|
240
|
+
* back, or null for a notification. Never throws.
|
|
241
|
+
*
|
|
242
|
+
* @param {object} message a parsed JSON-RPC request or notification
|
|
243
|
+
* @param {{cfg?: object, warn?: (line: string) => void}} [opts]
|
|
244
|
+
*/
|
|
245
|
+
export async function relay(message, opts = {}) {
|
|
246
|
+
const cfg = opts.cfg || bridgeConfig();
|
|
247
|
+
const warn = opts.warn || ((line) => process.stderr.write(`${line}\n`));
|
|
248
|
+
if (!message || typeof message !== 'object' || message.jsonrpc !== '2.0' || typeof message.method !== 'string') {
|
|
249
|
+
const id = message && typeof message === 'object' && 'id' in message ? message.id : null;
|
|
250
|
+
return rpcError(id ?? null, -32600, 'Invalid Request');
|
|
251
|
+
}
|
|
252
|
+
const isNotification = !('id' in message) || message.id === undefined;
|
|
253
|
+
const id = message.id;
|
|
254
|
+
|
|
255
|
+
if (isNotification) {
|
|
256
|
+
const out = await postToGateway(message, cfg);
|
|
257
|
+
if (out.kind !== 'http') warn(`${PACKAGE_NAME}: notification ${message.method} not delivered: ${unreachableText(cfg, out)}`);
|
|
258
|
+
return null;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
if (message.method === 'initialize') {
|
|
262
|
+
const params = { ...(message.params || {}) };
|
|
263
|
+
params.clientInfo = { ...(params.clientInfo || {}), name: bridgedClientName(params.clientInfo && params.clientInfo.name) };
|
|
264
|
+
if (!params.clientInfo.version) params.clientInfo.version = '0';
|
|
265
|
+
const out = await postToGateway({ ...message, params }, cfg);
|
|
266
|
+
noteTier(out, cfg, warn);
|
|
267
|
+
if (out.kind === 'http' && out.body && out.body.result && typeof out.body.result === 'object') {
|
|
268
|
+
const result = { ...out.body.result, serverInfo: { name: PACKAGE_NAME, version: VERSION } };
|
|
269
|
+
if (!cfg.metaTools) result.instructions = scopedInstructions();
|
|
270
|
+
return rpcResult(id, result);
|
|
271
|
+
}
|
|
272
|
+
// The host must still start: answer locally and let the calls report the
|
|
273
|
+
// gateway problem when they happen.
|
|
274
|
+
warn(`${PACKAGE_NAME}: initialize answered locally -- ${out.kind === 'http' ? `gateway HTTP ${out.status}` : unreachableText(cfg, out)}`);
|
|
275
|
+
return rpcResult(id, { ...localInitialize(message.params), instructions: scopedInstructions() });
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
if (message.method === 'tools/list') {
|
|
279
|
+
const out = await postToGateway(message, cfg);
|
|
280
|
+
noteTier(out, cfg, warn);
|
|
281
|
+
const listed = out.kind === 'http' && out.body && out.body.result && Array.isArray(out.body.result.tools)
|
|
282
|
+
? out.body.result : null;
|
|
283
|
+
if (listed) {
|
|
284
|
+
if (cfg.metaTools) return rpcResult(id, listed);
|
|
285
|
+
const own = listed.tools.filter((t) => t && t._meta && (t._meta.pack === GATEWAY_SLUG || t._meta.pack === SLUG));
|
|
286
|
+
if (own.length > 0) return rpcResult(id, { ...listed, tools: own });
|
|
287
|
+
warn(`${PACKAGE_NAME}: the gateway listed no ${SLUG} tools; serving the tool list bundled with this package`);
|
|
288
|
+
} else {
|
|
289
|
+
warn(`${PACKAGE_NAME}: tools/list served from the snapshot bundled with this package -- ${out.kind === 'http' ? `gateway HTTP ${out.status}` : unreachableText(cfg, out)}`);
|
|
290
|
+
}
|
|
291
|
+
return rpcResult(id, { tools });
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
if (message.method === 'tools/call') {
|
|
295
|
+
const out = await postToGateway(message, cfg);
|
|
296
|
+
noteTier(out, cfg, warn);
|
|
297
|
+
return toolsCallResponse(id, out, cfg);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// Everything else (ping, resources/*, prompts/*, ...): relay as-is.
|
|
301
|
+
const out = await postToGateway(message, cfg);
|
|
302
|
+
noteTier(out, cfg, warn);
|
|
303
|
+
if (out.kind === 'http' && out.body && out.body.jsonrpc === '2.0') return { ...out.body, id };
|
|
304
|
+
if (message.method === 'ping') return rpcResult(id, {});
|
|
305
|
+
return rpcError(id, -32603, out.kind === 'http'
|
|
306
|
+
? `The Pipeworx gateway returned HTTP ${out.status}: ${firstLine(out.text)}`
|
|
307
|
+
: unreachableText(cfg, out));
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Call one of this pack's tools through the gateway -- the `{tools, callTool}`
|
|
312
|
+
* shape earlier versions of this package exported. Resolves with the tool's
|
|
313
|
+
* structured result; rejects with the gateway's message on any error.
|
|
314
|
+
*
|
|
315
|
+
* @param {string} name
|
|
316
|
+
* @param {Record<string, unknown>} [args]
|
|
317
|
+
* @param {{apiKey?: string, gatewayUrl?: string, timeoutMs?: number}} [opts]
|
|
318
|
+
* apiKey defaults to process.env.PIPEWORX_API_KEY.
|
|
319
|
+
*/
|
|
320
|
+
export async function callTool(name, args = {}, opts = {}) {
|
|
321
|
+
const cfg = bridgeConfig(process.env, opts);
|
|
322
|
+
const res = await relay({ jsonrpc: '2.0', id: 1, method: 'tools/call', params: { name, arguments: args } }, { cfg });
|
|
323
|
+
if (res.error) throw new Error(res.error.message);
|
|
324
|
+
const result = res.result || {};
|
|
325
|
+
const text = Array.isArray(result.content)
|
|
326
|
+
? result.content.filter((c) => c && c.type === 'text').map((c) => c.text).join('\n')
|
|
327
|
+
: '';
|
|
328
|
+
if (result.isError) throw new Error(text || `${name} failed`);
|
|
329
|
+
if (result.structuredContent !== undefined) return result.structuredContent;
|
|
330
|
+
try { return JSON.parse(text); } catch { return text; }
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
export default { tools, callTool };
|
package/package.json
CHANGED
|
@@ -1,6 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pipeworx/mcp-cricsheet",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "cricsheet -- ball-by-ball cricket data collapsed to match / player / team questions (fleet #2975).",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "lib/index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./lib/index.js",
|
|
9
|
+
"./tools.json": "./tools.json",
|
|
10
|
+
"./package.json": "./package.json"
|
|
11
|
+
},
|
|
12
|
+
"bin": {
|
|
13
|
+
"mcp-cricsheet": "bin/cli.js"
|
|
14
|
+
},
|
|
15
|
+
"files": ["bin/", "lib/", "tools.json", "server.json"],
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=18"
|
|
18
|
+
},
|
|
19
|
+
"keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "cricsheet"],
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/pipeworx-io/mcp-cricsheet.git"
|
|
24
|
+
},
|
|
25
|
+
"mcpName": "io.github.pipeworx-io/cricsheet",
|
|
26
|
+
"pipeworx": {
|
|
27
|
+
"mode": "gateway",
|
|
28
|
+
"slug": "cricsheet",
|
|
29
|
+
"gatewaySlug": "cricsheet",
|
|
30
|
+
"sourceHash": "v1-2548fdf5bbdcc80b9040c95bd186cf1bea0ef4bb2bfa1445a893196cef88e6b2",
|
|
31
|
+
"sourceCommit": "0b3faaa4d85299a961dd86dea75a0f0e1dad280c"
|
|
32
|
+
}
|
|
33
|
+
}
|
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/cricsheet",
|
|
4
|
+
"title": "Cricsheet",
|
|
5
|
+
"description": "cricsheet -- ball-by-ball cricket data collapsed to match / player / team questions (fleet #2975).",
|
|
6
|
+
"version": "0.2.0",
|
|
7
|
+
"websiteUrl": "https://pipeworx.io/packs/cricsheet",
|
|
8
|
+
"repository": {
|
|
9
|
+
"url": "https://github.com/pipeworx-io/mcp-cricsheet",
|
|
10
|
+
"source": "github"
|
|
11
|
+
},
|
|
12
|
+
"remotes": [
|
|
13
|
+
{
|
|
14
|
+
"type": "streamable-http",
|
|
15
|
+
"url": "https://gateway.pipeworx.io/cricsheet/mcp"
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
package/tools.json
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"name": "cricsheet_match",
|
|
4
|
+
"description": "Full result and scorecard for one cricket match: teams, venue, date, toss, result, and for every innings the batting card (each batter's runs/balls/4s/6s/how out) and bowling card (each bowler's overs/runs/wickets). Covers Test, ODI and T20 International cricket plus the IPL (Cricsheet, ODC-BY). Use cricsheet_find_matches first to get a match_id if you don't already have one.",
|
|
5
|
+
"inputSchema": {
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"match_id": {
|
|
9
|
+
"type": "number",
|
|
10
|
+
"description": "Cricsheet match id, e.g. 1082591. Get one from cricsheet_find_matches."
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"required": [
|
|
14
|
+
"match_id"
|
|
15
|
+
]
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"name": "cricsheet_player_stats",
|
|
20
|
+
"description": "A cricketer's career batting and bowling aggregates (matches, runs, average, strike rate, 100s/50s; wickets, bowling average, economy) from Cricsheet's Test/ODI/T20I/IPL match data. Pass a name or partial name (\"Kohli\", \"V Kohli\") -- Cricsheet stores short-form names, so this matches case-insensitively and returns a candidate list if the name is ambiguous. Optionally scope to one format with `format`. Covers only matches Cricsheet has scored ball-by-ball, not a player's entire career.",
|
|
21
|
+
"inputSchema": {
|
|
22
|
+
"type": "object",
|
|
23
|
+
"properties": {
|
|
24
|
+
"player": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"description": "Player name or partial name, e.g. \"Kohli\" or \"V Kohli\"."
|
|
27
|
+
},
|
|
28
|
+
"format": {
|
|
29
|
+
"type": "string",
|
|
30
|
+
"description": "Match format: \"Test\", \"ODI\", \"T20I\" (international T20), or \"IPL\". Omit to search across every format this pack holds."
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"required": [
|
|
34
|
+
"player"
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"name": "cricsheet_head_to_head",
|
|
40
|
+
"description": "Head-to-head record between two cricket teams from Cricsheet's Test/ODI/T20I/IPL match data: total matches, each team's wins, ties/no-results, and the most recent matches with their results. Pass team names as Cricsheet uses them, e.g. \"India\", \"Australia\", \"Mumbai Indians\" (IPL). Optionally scope to one format with `format`.",
|
|
41
|
+
"inputSchema": {
|
|
42
|
+
"type": "object",
|
|
43
|
+
"properties": {
|
|
44
|
+
"team_a": {
|
|
45
|
+
"type": "string",
|
|
46
|
+
"description": "First team name, e.g. \"India\"."
|
|
47
|
+
},
|
|
48
|
+
"team_b": {
|
|
49
|
+
"type": "string",
|
|
50
|
+
"description": "Second team name, e.g. \"Australia\"."
|
|
51
|
+
},
|
|
52
|
+
"format": {
|
|
53
|
+
"type": "string",
|
|
54
|
+
"description": "Match format: \"Test\", \"ODI\", \"T20I\" (international T20), or \"IPL\". Omit to search across every format this pack holds."
|
|
55
|
+
},
|
|
56
|
+
"limit": {
|
|
57
|
+
"type": "number",
|
|
58
|
+
"description": "Max recent matches to list, 1-100. Default 10."
|
|
59
|
+
},
|
|
60
|
+
"offset": {
|
|
61
|
+
"type": "number",
|
|
62
|
+
"description": "Pagination offset into the recent-matches list. Default 0."
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"required": [
|
|
66
|
+
"team_a",
|
|
67
|
+
"team_b"
|
|
68
|
+
]
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"name": "cricsheet_find_matches",
|
|
73
|
+
"description": "Search Cricsheet's Test/ODI/T20I/IPL match index by team, format, season, venue and/or player, returning match_id plus date/teams/venue/result for each hit -- use this to discover match_ids for cricsheet_match. With no filters, returns the most recent matches across every format. Provide at least one filter to narrow a specific search.",
|
|
74
|
+
"inputSchema": {
|
|
75
|
+
"type": "object",
|
|
76
|
+
"properties": {
|
|
77
|
+
"team": {
|
|
78
|
+
"type": "string",
|
|
79
|
+
"description": "Team name, e.g. \"England\" or \"Chennai Super Kings\" (IPL)."
|
|
80
|
+
},
|
|
81
|
+
"format": {
|
|
82
|
+
"type": "string",
|
|
83
|
+
"description": "Match format: \"Test\", \"ODI\", \"T20I\" (international T20), or \"IPL\". Omit to search across every format this pack holds."
|
|
84
|
+
},
|
|
85
|
+
"season": {
|
|
86
|
+
"type": "string",
|
|
87
|
+
"description": "Season label as Cricsheet records it, e.g. \"2023\" or \"2007/08\"."
|
|
88
|
+
},
|
|
89
|
+
"venue": {
|
|
90
|
+
"type": "string",
|
|
91
|
+
"description": "Venue name or partial venue name, e.g. \"Lord's\"."
|
|
92
|
+
},
|
|
93
|
+
"player": {
|
|
94
|
+
"type": "string",
|
|
95
|
+
"description": "Exact player name as Cricsheet stores it (see cricsheet_player_stats to resolve a partial name first)."
|
|
96
|
+
},
|
|
97
|
+
"limit": {
|
|
98
|
+
"type": "number",
|
|
99
|
+
"description": "Max matches to return, 1-200. Default 50."
|
|
100
|
+
},
|
|
101
|
+
"offset": {
|
|
102
|
+
"type": "number",
|
|
103
|
+
"description": "Pagination offset. Default 0."
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"name": "cricsheet_chase_search",
|
|
110
|
+
"description": "Compound cricket match search on the second innings (the chase): filter limited-overs matches (ODI, T20I, IPL) by whether the side batting second won or lost, wickets remaining and balls remaining at the end of the chase, date range, season, tournament/event, team, gender and format. Each hit returns target, chase score, wickets lost, balls used, wickets_remaining (10 minus wickets lost) and balls_remaining (scheduled overs minus legal balls bowled; null for rain-affected matches decided by a method such as DLS). Example: T20I chases won with 5+ wickets and 10+ balls to spare since 2024. Source: Cricsheet match data (ODC-BY). Tests are excluded.",
|
|
111
|
+
"inputSchema": {
|
|
112
|
+
"type": "object",
|
|
113
|
+
"properties": {
|
|
114
|
+
"second_innings_result": {
|
|
115
|
+
"type": "string",
|
|
116
|
+
"enum": [
|
|
117
|
+
"won",
|
|
118
|
+
"lost",
|
|
119
|
+
"any"
|
|
120
|
+
],
|
|
121
|
+
"description": "Did the side batting second win? Default \"won\" (a successful chase)."
|
|
122
|
+
},
|
|
123
|
+
"format": {
|
|
124
|
+
"type": "string",
|
|
125
|
+
"description": "Match format: \"ODI\", \"T20I\" or \"IPL\". Omit for all three."
|
|
126
|
+
},
|
|
127
|
+
"min_wickets_remaining": {
|
|
128
|
+
"type": "number",
|
|
129
|
+
"description": "Chasing side had at least this many wickets in hand at the end (0-10)."
|
|
130
|
+
},
|
|
131
|
+
"max_wickets_remaining": {
|
|
132
|
+
"type": "number",
|
|
133
|
+
"description": "Chasing side had at most this many wickets in hand at the end (0-10)."
|
|
134
|
+
},
|
|
135
|
+
"min_balls_remaining": {
|
|
136
|
+
"type": "number",
|
|
137
|
+
"description": "At least this many legal balls unused at the end of the chase (assumes full scheduled overs; 120 in T20, 300 in ODI)."
|
|
138
|
+
},
|
|
139
|
+
"max_balls_remaining": {
|
|
140
|
+
"type": "number",
|
|
141
|
+
"description": "At most this many legal balls unused (0 = chase went to the last ball)."
|
|
142
|
+
},
|
|
143
|
+
"team": {
|
|
144
|
+
"type": "string",
|
|
145
|
+
"description": "Chasing team name as Cricsheet uses it, e.g. \"India\"."
|
|
146
|
+
},
|
|
147
|
+
"gender": {
|
|
148
|
+
"type": "string",
|
|
149
|
+
"enum": [
|
|
150
|
+
"male",
|
|
151
|
+
"female"
|
|
152
|
+
],
|
|
153
|
+
"description": "Men's or women's cricket."
|
|
154
|
+
},
|
|
155
|
+
"season": {
|
|
156
|
+
"type": "string",
|
|
157
|
+
"description": "Season label, e.g. \"2024\" or \"2023/24\"."
|
|
158
|
+
},
|
|
159
|
+
"event": {
|
|
160
|
+
"type": "string",
|
|
161
|
+
"description": "Tournament/event name or fragment, e.g. \"World Cup\" or \"Indian Premier League\"."
|
|
162
|
+
},
|
|
163
|
+
"date_from": {
|
|
164
|
+
"type": "string",
|
|
165
|
+
"description": "Earliest match date, YYYY-MM-DD."
|
|
166
|
+
},
|
|
167
|
+
"date_to": {
|
|
168
|
+
"type": "string",
|
|
169
|
+
"description": "Latest match date, YYYY-MM-DD."
|
|
170
|
+
},
|
|
171
|
+
"limit": {
|
|
172
|
+
"type": "number",
|
|
173
|
+
"description": "Max matches to return, 1-200. Default 25."
|
|
174
|
+
},
|
|
175
|
+
"offset": {
|
|
176
|
+
"type": "number",
|
|
177
|
+
"description": "Pagination offset. Default 0."
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
]
|