@pmxt/mcp 2.29.0 → 2.30.2
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 +111 -0
- package/dist/generated/tools.js +2 -2
- package/dist/server.js +12 -4
- package/package.json +1 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 PMXT
|
|
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,111 @@
|
|
|
1
|
+
# @pmxt/mcp
|
|
2
|
+
|
|
3
|
+
MCP server that exposes the [PMXT](https://pmxt.dev) unified prediction market API as tools for Claude and other AI agents.
|
|
4
|
+
|
|
5
|
+
One tool per API method. Same interface regardless of venue -- Polymarket, Kalshi, Limitless, Probable, Baozi, Myriad, Opinion, Metaculus, Smarkets, and more.
|
|
6
|
+
|
|
7
|
+
## Quick start
|
|
8
|
+
|
|
9
|
+
Add to your Claude Desktop config (`claude_desktop_config.json`):
|
|
10
|
+
|
|
11
|
+
```json
|
|
12
|
+
{
|
|
13
|
+
"mcpServers": {
|
|
14
|
+
"pmxt": {
|
|
15
|
+
"command": "npx",
|
|
16
|
+
"args": ["-y", "@pmxt/mcp"],
|
|
17
|
+
"env": {
|
|
18
|
+
"PMXT_API_KEY": "pmxt_live_..."
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Or run directly:
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
PMXT_API_KEY=pmxt_live_... npx @pmxt/mcp
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Get an API key at [pmxt.dev/dashboard](https://pmxt.dev/dashboard).
|
|
32
|
+
|
|
33
|
+
## Modes
|
|
34
|
+
|
|
35
|
+
The MCP server doesn't run prediction market logic itself -- it forwards every tool call to a PMXT API server over HTTP. Where that server lives depends on the mode:
|
|
36
|
+
|
|
37
|
+
**Hosted** -- Set `PMXT_API_KEY` and the server calls `https://api.pmxt.dev`. No local setup required; the hosted service manages exchange connections, caching, and rate limits for you.
|
|
38
|
+
|
|
39
|
+
**Local (sidecar)** -- If no API key is set, the server assumes you're running the PMXT core server locally on `http://localhost:3847`. This is useful for development, self-hosting, or when you want full control over the runtime. See the [pmxt core repo](https://github.com/pmxt-dev/pmxt) for how to run the server.
|
|
40
|
+
|
|
41
|
+
You can point at any PMXT-compatible server by setting `PMXT_API_URL` explicitly.
|
|
42
|
+
|
|
43
|
+
## Environment variables
|
|
44
|
+
|
|
45
|
+
| Variable | Description |
|
|
46
|
+
|----------|-------------|
|
|
47
|
+
| `PMXT_API_KEY` | API key for the hosted PMXT service |
|
|
48
|
+
| `PMXT_API_URL` | Override the API base URL (defaults based on mode) |
|
|
49
|
+
|
|
50
|
+
## Tools
|
|
51
|
+
|
|
52
|
+
Every tool requires an `exchange` parameter (e.g. `polymarket`, `kalshi`, `limitless`). Read-only tools are safe to call freely. Order-related tools (`createOrder`, `submitOrder`, `cancelOrder`) require explicit user confirmation -- they spend real money.
|
|
53
|
+
|
|
54
|
+
**Market discovery:** `fetchMarkets`, `fetchMarketsPaginated`, `fetchEvents`, `fetchEvent`, `fetchMarket`
|
|
55
|
+
|
|
56
|
+
**Order book & pricing:** `fetchOrderBook`, `fetchTrades`, `fetchOHLCV`, `getExecutionPrice`, `getExecutionPriceDetailed`
|
|
57
|
+
|
|
58
|
+
**Trading:** `buildOrder`, `createOrder`, `submitOrder`, `cancelOrder`
|
|
59
|
+
|
|
60
|
+
**Account:** `fetchBalance`, `fetchPositions`, `fetchOpenOrders`, `fetchClosedOrders`, `fetchAllOrders`, `fetchOrder`, `fetchMyTrades`, `loadMarkets`
|
|
61
|
+
|
|
62
|
+
## How it works
|
|
63
|
+
|
|
64
|
+
The server translates MCP tool calls into HTTP requests to the PMXT REST API:
|
|
65
|
+
|
|
66
|
+
1. Agent calls a tool (e.g. `fetchMarkets`) with flat `{ exchange, limit, query }` input
|
|
67
|
+
2. The server reconstructs positional arguments from the flat input using embedded arg specs
|
|
68
|
+
3. Sends `POST /api/{exchange}/{method}` with `{ args: [...] }` to the PMXT API
|
|
69
|
+
4. Returns the JSON response to the agent
|
|
70
|
+
|
|
71
|
+
## Auto-generation pipeline
|
|
72
|
+
|
|
73
|
+
The tool definitions in `src/generated/tools.ts` are **not hand-written**. They are generated from the PMXT core OpenAPI spec by `scripts/generate-tools.cjs`.
|
|
74
|
+
|
|
75
|
+
The full pipeline runs automatically on every PMXT release:
|
|
76
|
+
|
|
77
|
+
1. A new version tag (`v*`) is pushed to the [pmxt core repo](https://github.com/pmxt-dev/pmxt)
|
|
78
|
+
2. The [`sync-mcp.yml`](https://github.com/pmxt-dev/pmxt/blob/main/.github/workflows/sync-mcp.yml) GitHub Actions workflow triggers
|
|
79
|
+
3. It clones this repo, copies the latest spec files from core into `spec/`:
|
|
80
|
+
- [`core/src/server/openapi.yaml`](https://github.com/pmxt-dev/pmxt/blob/main/core/src/server/openapi.yaml) -- full API spec (endpoints, parameters, response schemas)
|
|
81
|
+
- [`core/src/server/method-verbs.json`](https://github.com/pmxt-dev/pmxt/blob/main/core/src/server/method-verbs.json) -- HTTP verb and positional argument metadata per method
|
|
82
|
+
4. Runs `node scripts/generate-tools.cjs` to regenerate `src/generated/tools.ts`
|
|
83
|
+
5. Bumps `package.json` to match the core version
|
|
84
|
+
6. Commits, tags, and pushes to this repo
|
|
85
|
+
7. Publishes to npm with `npm publish --provenance --access public`
|
|
86
|
+
|
|
87
|
+
**What the generator does:**
|
|
88
|
+
- Reads both spec files
|
|
89
|
+
- Skips streaming/internal methods (`watchOrderBook`, `close`, `healthCheck`, etc.)
|
|
90
|
+
- Flattens complex parameters into flat MCP tool input schemas
|
|
91
|
+
- Embeds `ArgSpec` metadata so the server can reconstruct positional args at runtime
|
|
92
|
+
- Adds annotations (`readOnlyHint`, `destructiveHint`, `idempotentHint`) per tool
|
|
93
|
+
- Marks order-related tools with a `credentials` input property
|
|
94
|
+
|
|
95
|
+
To regenerate locally:
|
|
96
|
+
|
|
97
|
+
```sh
|
|
98
|
+
npm run generate
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Development
|
|
102
|
+
|
|
103
|
+
```sh
|
|
104
|
+
npm install
|
|
105
|
+
npm run generate # regenerate tools from spec/
|
|
106
|
+
npm run build # compile TypeScript
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## License
|
|
110
|
+
|
|
111
|
+
MIT
|
package/dist/generated/tools.js
CHANGED
|
@@ -650,7 +650,7 @@ export const TOOLS = [
|
|
|
650
650
|
},
|
|
651
651
|
{
|
|
652
652
|
"name": "fetchEvents",
|
|
653
|
-
"description": "
|
|
653
|
+
"description": "Start here for discovery and search. Events are the top-level grouping in the data model: Event -> Market -> Outcome. An event is a broad topic (e.g., \"Who will win the 2028 presidential election?\"), a market is a specific tradeable question within that event (e.g., \"Will Kamala Harris win the 2028 presidential election?\"), and an outcome is the side you buy (e.g., \"Yes\" or \"No\"). When a user asks to \"find\", \"search for\", or \"look up\" a market, use this tool — they almost always mean the event-level topic. Each returned event includes its child markets. Supports optional keyword search, filtering, and pagination.",
|
|
654
654
|
"inputSchema": {
|
|
655
655
|
"type": "object",
|
|
656
656
|
"properties": {
|
|
@@ -844,7 +844,7 @@ export const TOOLS = [
|
|
|
844
844
|
},
|
|
845
845
|
{
|
|
846
846
|
"name": "fetchMarkets",
|
|
847
|
-
"description": "Fetch markets
|
|
847
|
+
"description": "Fetch individual tradeable contracts (markets). A market is a specific question like \"Will Kamala Harris win the 2028 presidential election?\" — for general discovery or search, prefer fetchEvents instead, which returns the higher-level topic (e.g., \"Who will win the 2028 presidential election?\") with all its markets grouped together. When users say \"search for a market\" they almost always mean an event. Use fetchMarkets when you need a specific contract by ID/slug, or when you already have an eventId and want its child markets. Always hits the exchange API — results reflect the live state at the time of the call.",
|
|
848
848
|
"inputSchema": {
|
|
849
849
|
"type": "object",
|
|
850
850
|
"properties": {
|
package/dist/server.js
CHANGED
|
@@ -14,6 +14,12 @@ Same methods, same response shape, regardless of venue.
|
|
|
14
14
|
|
|
15
15
|
SETUP: Get an API key at pmxt.dev/dashboard. Set PMXT_API_KEY in your environment.
|
|
16
16
|
|
|
17
|
+
DATA MODEL (Event -> Market -> Outcome):
|
|
18
|
+
- Event: a broad topic, e.g. "Who will win the 2028 presidential election?"
|
|
19
|
+
- Market: a specific tradeable question within an event, e.g. "Will Kamala Harris win the 2028 presidential election?"
|
|
20
|
+
- Outcome: the side you buy or sell, e.g. "Yes" (she wins) or "No" (she does not win).
|
|
21
|
+
When users say "market" they almost always mean an event. Use fetchEvents for discovery and search.
|
|
22
|
+
|
|
17
23
|
IMPORTANT RULES:
|
|
18
24
|
- NEVER place orders (createOrder, submitOrder) without explicit user confirmation. \
|
|
19
25
|
These spend real money. Always show the user the order details (venue, market, side, price, amount) and wait for approval.
|
|
@@ -22,10 +28,12 @@ These spend real money. Always show the user the order details (venue, market, s
|
|
|
22
28
|
- Venue credentials (privateKey, apiKey) are sensitive. Never log or display them.
|
|
23
29
|
|
|
24
30
|
WORKFLOW:
|
|
25
|
-
1. Use
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
31
|
+
1. Use fetchEvents to discover and search for topics (use the "query" param). This is the right starting point \
|
|
32
|
+
even when the user says "market" -- they almost always mean an event. Each event includes its child markets.
|
|
33
|
+
2. Use fetchMarkets only when you need a specific contract by ID/slug, or to list markets within a known event.
|
|
34
|
+
3. Use fetchOrderBook to check liquidity and prices.
|
|
35
|
+
4. Use getExecutionPrice to quote a trade before placing it.
|
|
36
|
+
5. Use buildOrder to preview, then submitOrder to execute (with user approval).
|
|
29
37
|
|
|
30
38
|
The "exchange" param is required on every call. Options: polymarket, kalshi, limitless, probable, etc.`;
|
|
31
39
|
export function createServer(config) {
|