@sharpe-terminal/mcp-server 1.4.0 → 1.6.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/README.md +17 -7
- package/dist/api-client.d.ts +38 -1
- package/dist/api-client.d.ts.map +1 -1
- package/dist/api-client.js +119 -10
- package/dist/api-client.js.map +1 -1
- package/dist/composite-tools.d.ts +27 -45
- package/dist/composite-tools.d.ts.map +1 -1
- package/dist/composite-tools.js +372 -546
- package/dist/composite-tools.js.map +1 -1
- package/dist/contracts/manifest.d.ts +52 -0
- package/dist/contracts/manifest.d.ts.map +1 -0
- package/dist/contracts/manifest.js +9 -0
- package/dist/contracts/manifest.js.map +1 -0
- package/dist/endpoint-tools.d.ts +107 -0
- package/dist/endpoint-tools.d.ts.map +1 -0
- package/dist/endpoint-tools.js +382 -0
- package/dist/endpoint-tools.js.map +1 -0
- package/dist/server.d.ts +20 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +143 -101
- package/dist/server.js.map +1 -1
- package/dist/tool-runtime.d.ts +33 -38
- package/dist/tool-runtime.d.ts.map +1 -1
- package/dist/tool-runtime.js +113 -238
- package/dist/tool-runtime.js.map +1 -1
- package/package.json +1 -1
- package/dist/tools.d.ts +0 -567
- package/dist/tools.d.ts.map +0 -1
- package/dist/tools.js +0 -1166
- package/dist/tools.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../../src/contracts/manifest.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAsCH,sGAAsG;AACtG,MAAM,CAAC,MAAM,QAAQ,GAAkB,IAAI,CAAC,KAAK,CAAC,o56YAAo56Y,CAAkB,CAAC"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The endpoint tools, built from the agent manifest (WP-U12, design L6-D1 §3.1): one tool per contract with an agent
|
|
3
|
+
* block, named, described, validated and routed by src/contracts through the synced manifest
|
|
4
|
+
* (./contracts/manifest.ts, scripts/contracts/sync-packages.ts). Nothing here names an endpoint's path or re-types a
|
|
5
|
+
* parameter; the Python server (packages/mcp-server-python/server.py) implements the same steps over the same
|
|
6
|
+
* document, and scripts/contracts/parity.ts proves the two answer alike.
|
|
7
|
+
*
|
|
8
|
+
* A call: check the arguments against the tool's input schema, fill its defaults, pick the route (v1 with a key, the
|
|
9
|
+
* free twin without one), and answer `{ data, pagination?, meta }`: `data` as the route served it, `meta` what the API
|
|
10
|
+
* said about its freshness and what the client cut to fit the context window.
|
|
11
|
+
*
|
|
12
|
+
* Three client rules remain, each declared below with the change that retires it: a default page for two tools
|
|
13
|
+
* (REQUEST_DEFAULTS), paging for four free twins that ignore limit/cursor (KEYLESS_PAGING), and the oi-snapshot
|
|
14
|
+
* reading per exchange the futures contract promises (LATEST_PER_EXCHANGE).
|
|
15
|
+
*/
|
|
16
|
+
import { type ApiCaller, type DataFreshness, type RawAnswer } from "./api-client.ts";
|
|
17
|
+
import { type JsonSchema, type ManifestTool } from "./contracts/manifest.ts";
|
|
18
|
+
export declare const ENDPOINT_TOOLS: readonly ManifestTool[];
|
|
19
|
+
export declare function endpointTool(name: string): ManifestTool;
|
|
20
|
+
/** The v1 route and the route a keyless call reads (the free twin, or v1 when there is none). */
|
|
21
|
+
export declare function toolRoutes(tool: ManifestTool): {
|
|
22
|
+
apiPath: string;
|
|
23
|
+
fallbackPath: string;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Arguments a tool sends when the caller left them out, unless one of `unlessPresent` was given or an argument equals
|
|
27
|
+
* a value in `unlessEqual`. Retire into the contract's agent block (a declared agent default) at the next
|
|
28
|
+
* src/contracts change:
|
|
29
|
+
* - get_funding_rates: the unpaged book is ~13,000 rows (6 MB) of which MAX_ITEMS survive; one page comes with a
|
|
30
|
+
* cursor (0.3 s instead of 1.8 s, 2026-09-26). A coin, history or an aggregate answers small, and an aggregate
|
|
31
|
+
* refuses a page.
|
|
32
|
+
* - get_gem_finder: a keyed call pages at 100 as a keyless one does (KEYLESS_PAGING).
|
|
33
|
+
*/
|
|
34
|
+
export declare const REQUEST_DEFAULTS: Readonly<Record<string, {
|
|
35
|
+
set: Readonly<Record<string, string | number | boolean>>;
|
|
36
|
+
unlessPresent: readonly string[];
|
|
37
|
+
unlessEqual?: Readonly<Record<string, string>>;
|
|
38
|
+
}>>;
|
|
39
|
+
/**
|
|
40
|
+
* Free twins that ignore `limit`/`cursor` although v1 pages (their routes read only tab, type/symbol/venue/days,
|
|
41
|
+
* chart/coin/timeframe/exchanges, nothing): a keyless call with `limit` pages the rows the free body holds with v1's
|
|
42
|
+
* cursor, so a keyless agent reaches every row. `rows` is where the body holds them ("" = the body is the array);
|
|
43
|
+
* `answer` is "rows" when the page is the answer (v1's paged shape), "body" when the body keeps its other fields.
|
|
44
|
+
* Retire when the free routes read limit/cursor (L5) and their contracts declare `public.query`.
|
|
45
|
+
*/
|
|
46
|
+
export declare const KEYLESS_PAGING: Readonly<Record<string, {
|
|
47
|
+
rows: string;
|
|
48
|
+
answer: "rows" | "body";
|
|
49
|
+
cursor: "offset" | "snapshot";
|
|
50
|
+
snapshotField?: string;
|
|
51
|
+
}>>;
|
|
52
|
+
/**
|
|
53
|
+
* get_futures_data's contract promises "Without limit, oi-snapshot returns each exchange's latest reading", while both
|
|
54
|
+
* routes answer the whole ascending window (up to 5,000 raw rows): without `limit`, the client keeps each exchange's
|
|
55
|
+
* newest row, largest open interest first. Retire when the route serves the snapshot itself.
|
|
56
|
+
*/
|
|
57
|
+
export declare const LATEST_PER_EXCHANGE: Readonly<Record<string, {
|
|
58
|
+
when: Readonly<Record<string, string>>;
|
|
59
|
+
rows: string;
|
|
60
|
+
}>>;
|
|
61
|
+
export declare class ToolInputError extends Error {
|
|
62
|
+
}
|
|
63
|
+
type Scalar = string | number | boolean;
|
|
64
|
+
/** Why a value breaks its property schema, or null. The Python server words each issue the same way. */
|
|
65
|
+
export declare function propertyIssue(name: string, value: unknown, schema: JsonSchema): string | null;
|
|
66
|
+
/**
|
|
67
|
+
* The wire arguments of a call, checked against the tool's input schema and completed with its defaults, in the
|
|
68
|
+
* schema's order. `null` stands for an argument left out. Throws ToolInputError naming every issue.
|
|
69
|
+
*/
|
|
70
|
+
export declare function prepareArguments(tool: ManifestTool, args: Record<string, unknown>): Record<string, Scalar>;
|
|
71
|
+
/** The query string values: JSON numbers as JavaScript prints them, booleans as `true` / `false`. */
|
|
72
|
+
export declare function queryOf(args: Record<string, Scalar>): Record<string, string>;
|
|
73
|
+
export interface Page {
|
|
74
|
+
cursor: string | null;
|
|
75
|
+
has_more: boolean;
|
|
76
|
+
total: number | null;
|
|
77
|
+
}
|
|
78
|
+
/** Each exchange's newest row, largest open interest first. */
|
|
79
|
+
export declare function latestRowPerExchange(rows: unknown[]): unknown[];
|
|
80
|
+
export interface ToolResultMeta {
|
|
81
|
+
route: "v1" | "public";
|
|
82
|
+
dataset_id?: string;
|
|
83
|
+
as_of?: string | null;
|
|
84
|
+
stale_after?: string | null;
|
|
85
|
+
freshness_status?: DataFreshness["freshness_status"];
|
|
86
|
+
runtime_status?: DataFreshness["runtime_status"];
|
|
87
|
+
served_from?: string;
|
|
88
|
+
warnings: string[];
|
|
89
|
+
truncated?: true;
|
|
90
|
+
truncated_fields?: Record<string, {
|
|
91
|
+
total: number;
|
|
92
|
+
showing: number;
|
|
93
|
+
kept?: "latest";
|
|
94
|
+
}>;
|
|
95
|
+
truncation_message?: string;
|
|
96
|
+
}
|
|
97
|
+
export interface ToolResult {
|
|
98
|
+
data: unknown;
|
|
99
|
+
pagination?: Page;
|
|
100
|
+
meta: ToolResultMeta;
|
|
101
|
+
}
|
|
102
|
+
/** The answer of a route turned into the tool result (no I/O; the parity harness and the tests call it too). */
|
|
103
|
+
export declare function toolResult(tool: ManifestTool, args: Record<string, Scalar>, answer: RawAnswer): ToolResult;
|
|
104
|
+
/** Calls an endpoint tool: validated arguments, the route the key picks, the result. */
|
|
105
|
+
export declare function callEndpointTool(tool: ManifestTool, args: Record<string, unknown>, callApi: ApiCaller): Promise<ToolResult>;
|
|
106
|
+
export {};
|
|
107
|
+
//# sourceMappingURL=endpoint-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endpoint-tools.d.ts","sourceRoot":"","sources":["../src/endpoint-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAIL,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,SAAS,EACf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAEL,KAAK,UAAU,EACf,KAAK,YAAY,EAClB,MAAM,yBAAyB,CAAC;AAQjC,eAAO,MAAM,cAAc,EAAE,SAAS,YAAY,EAAmB,CAAC;AAItE,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAIvD;AAED,iGAAiG;AACjG,wBAAgB,UAAU,CAAC,IAAI,EAAE,YAAY,GAAG;IAC9C,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;CACtB,CAIA;AAID;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CACrC,MAAM,CACJ,MAAM,EACN;IACE,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IACzD,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,WAAW,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CAChD,CACF,CAQF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,EAAE,QAAQ,CACnC,MAAM,CACJ,MAAM,EACN;IACE,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,MAAM,EAAE,QAAQ,GAAG,UAAU,CAAC;IAC9B,aAAa,CAAC,EA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AG,IAAI,CAAC;IAC5B,gBAAgB,CAAC,EAAE,aAAa,CAAC,kBAAkB,CAAC,CAAC;IACrD,cAAc,CAAC,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;IACjD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,gBAAgB,CAAC,EAAE,MAAM,CACvB,MAAM,EACN;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,QAAQ,CAAA;KAAE,CACpD,CAAC;IACF,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,OAAO,CAAC;IACd,UAAU,CAAC,EAAE,IAAI,CAAC;IAClB,IAAI,EAAE,cAAc,CAAC;CACtB;AAMD,gHAAgH;AAChH,wBAAgB,UAAU,CACxB,IAAI,EAAE,YAAY,EAClB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC5B,MAAM,EAAE,SAAS,GAChB,UAAU,CA+DZ;AAED,wFAAwF;AACxF,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,YAAY,EAClB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,EAAE,SAAS,GACjB,OAAO,CAAC,UAAU,CAAC,CAYrB"}
|
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The endpoint tools, built from the agent manifest (WP-U12, design L6-D1 §3.1): one tool per contract with an agent
|
|
3
|
+
* block, named, described, validated and routed by src/contracts through the synced manifest
|
|
4
|
+
* (./contracts/manifest.ts, scripts/contracts/sync-packages.ts). Nothing here names an endpoint's path or re-types a
|
|
5
|
+
* parameter; the Python server (packages/mcp-server-python/server.py) implements the same steps over the same
|
|
6
|
+
* document, and scripts/contracts/parity.ts proves the two answer alike.
|
|
7
|
+
*
|
|
8
|
+
* A call: check the arguments against the tool's input schema, fill its defaults, pick the route (v1 with a key, the
|
|
9
|
+
* free twin without one), and answer `{ data, pagination?, meta }`: `data` as the route served it, `meta` what the API
|
|
10
|
+
* said about its freshness and what the client cut to fit the context window.
|
|
11
|
+
*
|
|
12
|
+
* Three client rules remain, each declared below with the change that retires it: a default page for two tools
|
|
13
|
+
* (REQUEST_DEFAULTS), paging for four free twins that ignore limit/cursor (KEYLESS_PAGING), and the oi-snapshot
|
|
14
|
+
* reading per exchange the futures contract promises (LATEST_PER_EXCHANGE).
|
|
15
|
+
*/
|
|
16
|
+
import { freshnessFromHeaders, freshnessFromMeta, headerPagination, } from "./api-client.js";
|
|
17
|
+
import { MANIFEST, } from "./contracts/manifest.js";
|
|
18
|
+
import { MAX_ITEMS, TRUNCATION_MESSAGE, capToContext, rowTimeMs, } from "./tool-runtime.js";
|
|
19
|
+
export const ENDPOINT_TOOLS = MANIFEST.tools;
|
|
20
|
+
const TOOLS_BY_NAME = new Map(ENDPOINT_TOOLS.map((tool) => [tool.name, tool]));
|
|
21
|
+
export function endpointTool(name) {
|
|
22
|
+
const tool = TOOLS_BY_NAME.get(name);
|
|
23
|
+
if (tool === undefined)
|
|
24
|
+
throw new Error(`No endpoint tool ${name}`);
|
|
25
|
+
return tool;
|
|
26
|
+
}
|
|
27
|
+
/** The v1 route and the route a keyless call reads (the free twin, or v1 when there is none). */
|
|
28
|
+
export function toolRoutes(tool) {
|
|
29
|
+
const apiPath = tool.routes.v1 ?? tool.routes.public;
|
|
30
|
+
if (apiPath === null)
|
|
31
|
+
throw new Error(`${tool.name} has no route`);
|
|
32
|
+
return { apiPath, fallbackPath: tool.routes.public ?? apiPath };
|
|
33
|
+
}
|
|
34
|
+
// ── Declared client rules (identical in server.py; pinned by scripts/contracts/parity.ts) ──
|
|
35
|
+
/**
|
|
36
|
+
* Arguments a tool sends when the caller left them out, unless one of `unlessPresent` was given or an argument equals
|
|
37
|
+
* a value in `unlessEqual`. Retire into the contract's agent block (a declared agent default) at the next
|
|
38
|
+
* src/contracts change:
|
|
39
|
+
* - get_funding_rates: the unpaged book is ~13,000 rows (6 MB) of which MAX_ITEMS survive; one page comes with a
|
|
40
|
+
* cursor (0.3 s instead of 1.8 s, 2026-09-26). A coin, history or an aggregate answers small, and an aggregate
|
|
41
|
+
* refuses a page.
|
|
42
|
+
* - get_gem_finder: a keyed call pages at 100 as a keyless one does (KEYLESS_PAGING).
|
|
43
|
+
*/
|
|
44
|
+
export const REQUEST_DEFAULTS = {
|
|
45
|
+
get_funding_rates: {
|
|
46
|
+
set: { limit: MAX_ITEMS },
|
|
47
|
+
unlessPresent: ["limit", "cursor", "coin", "extremes", "stats", "summary"],
|
|
48
|
+
unlessEqual: { type: "history" },
|
|
49
|
+
},
|
|
50
|
+
get_gem_finder: { set: { limit: 100 }, unlessPresent: ["limit"] },
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Free twins that ignore `limit`/`cursor` although v1 pages (their routes read only tab, type/symbol/venue/days,
|
|
54
|
+
* chart/coin/timeframe/exchanges, nothing): a keyless call with `limit` pages the rows the free body holds with v1's
|
|
55
|
+
* cursor, so a keyless agent reaches every row. `rows` is where the body holds them ("" = the body is the array);
|
|
56
|
+
* `answer` is "rows" when the page is the answer (v1's paged shape), "body" when the body keeps its other fields.
|
|
57
|
+
* Retire when the free routes read limit/cursor (L5) and their contracts declare `public.query`.
|
|
58
|
+
*/
|
|
59
|
+
export const KEYLESS_PAGING = {
|
|
60
|
+
get_global_overview: { rows: "rows", answer: "rows", cursor: "offset" },
|
|
61
|
+
get_rwa_perp_funding: { rows: "", answer: "rows", cursor: "offset" },
|
|
62
|
+
get_futures_data: { rows: "data", answer: "body", cursor: "offset" },
|
|
63
|
+
get_gem_finder: {
|
|
64
|
+
rows: "coins",
|
|
65
|
+
answer: "rows",
|
|
66
|
+
cursor: "snapshot",
|
|
67
|
+
snapshotField: "updatedAt",
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* get_futures_data's contract promises "Without limit, oi-snapshot returns each exchange's latest reading", while both
|
|
72
|
+
* routes answer the whole ascending window (up to 5,000 raw rows): without `limit`, the client keeps each exchange's
|
|
73
|
+
* newest row, largest open interest first. Retire when the route serves the snapshot itself.
|
|
74
|
+
*/
|
|
75
|
+
export const LATEST_PER_EXCHANGE = {
|
|
76
|
+
get_futures_data: { when: { chart: "oi-snapshot" }, rows: "data" },
|
|
77
|
+
};
|
|
78
|
+
// ── Arguments ──
|
|
79
|
+
export class ToolInputError extends Error {
|
|
80
|
+
}
|
|
81
|
+
function propertiesOf(schema) {
|
|
82
|
+
const properties = schema.properties;
|
|
83
|
+
return properties && typeof properties === "object"
|
|
84
|
+
? properties
|
|
85
|
+
: {};
|
|
86
|
+
}
|
|
87
|
+
function describeType(type) {
|
|
88
|
+
return type === "integer"
|
|
89
|
+
? "an integer"
|
|
90
|
+
: type === "number"
|
|
91
|
+
? "a number"
|
|
92
|
+
: type === "boolean"
|
|
93
|
+
? "a boolean"
|
|
94
|
+
: "a string";
|
|
95
|
+
}
|
|
96
|
+
/** Why a value breaks its property schema, or null. The Python server words each issue the same way. */
|
|
97
|
+
export function propertyIssue(name, value, schema) {
|
|
98
|
+
const type = schema.type;
|
|
99
|
+
const typeOk = type === "integer"
|
|
100
|
+
? typeof value === "number" && Number.isInteger(value)
|
|
101
|
+
: type === "number"
|
|
102
|
+
? typeof value === "number" && Number.isFinite(value)
|
|
103
|
+
: type === "boolean"
|
|
104
|
+
? typeof value === "boolean"
|
|
105
|
+
: typeof value === "string";
|
|
106
|
+
if (!typeOk)
|
|
107
|
+
return `"${name}" must be ${describeType(type)}`;
|
|
108
|
+
if (Array.isArray(schema.enum) && !schema.enum.includes(value)) {
|
|
109
|
+
return `"${name}" must be one of: ${schema.enum.join(", ")}`;
|
|
110
|
+
}
|
|
111
|
+
if (typeof value === "number") {
|
|
112
|
+
if (typeof schema.minimum === "number" && value < schema.minimum) {
|
|
113
|
+
return `"${name}" must be >= ${schema.minimum}`;
|
|
114
|
+
}
|
|
115
|
+
if (typeof schema.maximum === "number" && value > schema.maximum) {
|
|
116
|
+
return `"${name}" must be <= ${schema.maximum}`;
|
|
117
|
+
}
|
|
118
|
+
if (typeof schema.exclusiveMinimum === "number" &&
|
|
119
|
+
value <= schema.exclusiveMinimum) {
|
|
120
|
+
return `"${name}" must be > ${schema.exclusiveMinimum}`;
|
|
121
|
+
}
|
|
122
|
+
if (typeof schema.exclusiveMaximum === "number" &&
|
|
123
|
+
value >= schema.exclusiveMaximum) {
|
|
124
|
+
return `"${name}" must be < ${schema.exclusiveMaximum}`;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if (typeof value === "string") {
|
|
128
|
+
const length = [...value].length;
|
|
129
|
+
if (typeof schema.minLength === "number" && length < schema.minLength) {
|
|
130
|
+
return `"${name}" must be at least ${schema.minLength} characters`;
|
|
131
|
+
}
|
|
132
|
+
if (typeof schema.maxLength === "number" && length > schema.maxLength) {
|
|
133
|
+
return `"${name}" must be at most ${schema.maxLength} characters`;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* The wire arguments of a call, checked against the tool's input schema and completed with its defaults, in the
|
|
140
|
+
* schema's order. `null` stands for an argument left out. Throws ToolInputError naming every issue.
|
|
141
|
+
*/
|
|
142
|
+
export function prepareArguments(tool, args) {
|
|
143
|
+
const properties = propertiesOf(tool.input_schema);
|
|
144
|
+
const issues = [];
|
|
145
|
+
for (const name of Object.keys(args)) {
|
|
146
|
+
if (!(name in properties))
|
|
147
|
+
issues.push(`unknown argument "${name}"`);
|
|
148
|
+
}
|
|
149
|
+
const required = Array.isArray(tool.input_schema.required)
|
|
150
|
+
? tool.input_schema.required
|
|
151
|
+
: [];
|
|
152
|
+
const out = {};
|
|
153
|
+
for (const [name, schema] of Object.entries(properties)) {
|
|
154
|
+
const given = args[name];
|
|
155
|
+
if (given === undefined || given === null) {
|
|
156
|
+
if (required.includes(name))
|
|
157
|
+
issues.push(`"${name}" is required`);
|
|
158
|
+
else if (schema.default !== undefined)
|
|
159
|
+
out[name] = schema.default;
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
const issue = propertyIssue(name, given, schema);
|
|
163
|
+
if (issue !== null)
|
|
164
|
+
issues.push(issue);
|
|
165
|
+
else
|
|
166
|
+
out[name] = given;
|
|
167
|
+
}
|
|
168
|
+
if (issues.length > 0) {
|
|
169
|
+
throw new ToolInputError(`Invalid arguments for ${tool.name}: ${issues.join("; ")}`);
|
|
170
|
+
}
|
|
171
|
+
const rule = REQUEST_DEFAULTS[tool.name];
|
|
172
|
+
if (rule !== undefined &&
|
|
173
|
+
!rule.unlessPresent.some((name) => name in args && args[name] != null) &&
|
|
174
|
+
!Object.entries(rule.unlessEqual ?? {}).some(([name, value]) => out[name] === value)) {
|
|
175
|
+
for (const [name, value] of Object.entries(rule.set))
|
|
176
|
+
out[name] = value;
|
|
177
|
+
}
|
|
178
|
+
return out;
|
|
179
|
+
}
|
|
180
|
+
/** The query string values: JSON numbers as JavaScript prints them, booleans as `true` / `false`. */
|
|
181
|
+
export function queryOf(args) {
|
|
182
|
+
return Object.fromEntries(Object.entries(args).map(([name, value]) => [name, String(value)]));
|
|
183
|
+
}
|
|
184
|
+
// ── Paging a free body ──
|
|
185
|
+
function encodeOffset(offset) {
|
|
186
|
+
return Buffer.from(String(offset)).toString("base64url");
|
|
187
|
+
}
|
|
188
|
+
function decodeOffset(cursor) {
|
|
189
|
+
const decoded = /^[A-Za-z0-9_-]+$/.test(cursor)
|
|
190
|
+
? Buffer.from(cursor, "base64url").toString("utf8")
|
|
191
|
+
: "";
|
|
192
|
+
if (!/^\d+$/.test(decoded))
|
|
193
|
+
throw new Error("Invalid pagination cursor.");
|
|
194
|
+
return Number(decoded);
|
|
195
|
+
}
|
|
196
|
+
function encodeSnapshot(snapshot, offset) {
|
|
197
|
+
return Buffer.from(JSON.stringify({ version: 1, snapshot, offset })).toString("base64url");
|
|
198
|
+
}
|
|
199
|
+
function decodeSnapshot(cursor, snapshot) {
|
|
200
|
+
let payload;
|
|
201
|
+
try {
|
|
202
|
+
payload = JSON.parse(Buffer.from(cursor, "base64url").toString("utf8"));
|
|
203
|
+
}
|
|
204
|
+
catch {
|
|
205
|
+
throw new Error("Invalid pagination cursor.");
|
|
206
|
+
}
|
|
207
|
+
if (!payload ||
|
|
208
|
+
payload.version !== 1 ||
|
|
209
|
+
typeof payload.snapshot !== "string" ||
|
|
210
|
+
payload.snapshot === "" ||
|
|
211
|
+
typeof payload.offset !== "number" ||
|
|
212
|
+
!Number.isInteger(payload.offset) ||
|
|
213
|
+
payload.offset < 0) {
|
|
214
|
+
throw new Error("Invalid pagination cursor.");
|
|
215
|
+
}
|
|
216
|
+
if (payload.snapshot !== snapshot) {
|
|
217
|
+
throw new Error("The pagination cursor belongs to an expired snapshot. Restart without a cursor.");
|
|
218
|
+
}
|
|
219
|
+
return payload.offset;
|
|
220
|
+
}
|
|
221
|
+
function isRecord(value) {
|
|
222
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
223
|
+
}
|
|
224
|
+
function rowsAt(body, path) {
|
|
225
|
+
const value = path === "" ? body : isRecord(body) ? body[path] : undefined;
|
|
226
|
+
return Array.isArray(value) ? value : null;
|
|
227
|
+
}
|
|
228
|
+
function pageFreeBody(toolName, body, args) {
|
|
229
|
+
const rule = KEYLESS_PAGING[toolName];
|
|
230
|
+
if (rule === undefined || typeof args.limit !== "number")
|
|
231
|
+
return null;
|
|
232
|
+
const rows = rowsAt(body, rule.rows);
|
|
233
|
+
if (rows === null)
|
|
234
|
+
return null;
|
|
235
|
+
const cursor = typeof args.cursor === "string" ? args.cursor : null;
|
|
236
|
+
const snapshot = rule.cursor === "snapshot" && isRecord(body)
|
|
237
|
+
? typeof body[rule.snapshotField ?? ""] === "string" &&
|
|
238
|
+
body[rule.snapshotField ?? ""] !== ""
|
|
239
|
+
? body[rule.snapshotField ?? ""]
|
|
240
|
+
: "empty-snapshot"
|
|
241
|
+
: "";
|
|
242
|
+
const offset = cursor === null
|
|
243
|
+
? 0
|
|
244
|
+
: rule.cursor === "snapshot"
|
|
245
|
+
? decodeSnapshot(cursor, snapshot)
|
|
246
|
+
: decodeOffset(cursor);
|
|
247
|
+
const next = offset + args.limit;
|
|
248
|
+
const hasMore = next < rows.length;
|
|
249
|
+
const page = rows.slice(offset, next);
|
|
250
|
+
const pagination = {
|
|
251
|
+
cursor: hasMore
|
|
252
|
+
? rule.cursor === "snapshot"
|
|
253
|
+
? encodeSnapshot(snapshot, next)
|
|
254
|
+
: encodeOffset(next)
|
|
255
|
+
: null,
|
|
256
|
+
has_more: hasMore,
|
|
257
|
+
total: rows.length,
|
|
258
|
+
};
|
|
259
|
+
if (rule.answer === "rows" || rule.rows === "") {
|
|
260
|
+
return { data: page, pagination };
|
|
261
|
+
}
|
|
262
|
+
return { data: { ...body, [rule.rows]: page }, pagination };
|
|
263
|
+
}
|
|
264
|
+
/** Each exchange's newest row, largest open interest first. */
|
|
265
|
+
export function latestRowPerExchange(rows) {
|
|
266
|
+
const latest = new Map();
|
|
267
|
+
for (const row of rows) {
|
|
268
|
+
const at = rowTimeMs(row);
|
|
269
|
+
if (!isRecord(row) || at == null)
|
|
270
|
+
continue;
|
|
271
|
+
const exchange = String(row.exchange ?? "");
|
|
272
|
+
const prev = latest.get(exchange);
|
|
273
|
+
if (!prev || at >= prev.at)
|
|
274
|
+
latest.set(exchange, { row, at });
|
|
275
|
+
}
|
|
276
|
+
const oiOf = (row) => {
|
|
277
|
+
const value = row.open_interest_value;
|
|
278
|
+
return typeof value === "number" && Number.isFinite(value)
|
|
279
|
+
? value
|
|
280
|
+
: Number.NEGATIVE_INFINITY;
|
|
281
|
+
};
|
|
282
|
+
return [...latest.values()]
|
|
283
|
+
.map((entry) => entry.row)
|
|
284
|
+
.sort((a, b) => oiOf(b) - oiOf(a));
|
|
285
|
+
}
|
|
286
|
+
function reduceToLatest(toolName, data, args) {
|
|
287
|
+
const rule = LATEST_PER_EXCHANGE[toolName];
|
|
288
|
+
if (rule === undefined ||
|
|
289
|
+
"limit" in args ||
|
|
290
|
+
!Object.entries(rule.when).every(([name, value]) => args[name] === value)) {
|
|
291
|
+
return data;
|
|
292
|
+
}
|
|
293
|
+
const rows = rowsAt(data, rule.rows);
|
|
294
|
+
return rows === null || !isRecord(data)
|
|
295
|
+
? data
|
|
296
|
+
: { ...data, [rule.rows]: latestRowPerExchange(rows) };
|
|
297
|
+
}
|
|
298
|
+
function isPage(value) {
|
|
299
|
+
return isRecord(value) && typeof value.has_more === "boolean";
|
|
300
|
+
}
|
|
301
|
+
/** The answer of a route turned into the tool result (no I/O; the parity harness and the tests call it too). */
|
|
302
|
+
export function toolResult(tool, args, answer) {
|
|
303
|
+
const { route, body, headers } = answer;
|
|
304
|
+
let data;
|
|
305
|
+
let pagination;
|
|
306
|
+
let freshness;
|
|
307
|
+
if (route === "v1" && isRecord(body) && "data" in body) {
|
|
308
|
+
data = body.data;
|
|
309
|
+
if (isPage(body.pagination))
|
|
310
|
+
pagination = body.pagination;
|
|
311
|
+
freshness = freshnessFromMeta(body.meta) ?? freshnessFromHeaders(headers);
|
|
312
|
+
}
|
|
313
|
+
else {
|
|
314
|
+
data = body;
|
|
315
|
+
if (Array.isArray(body)) {
|
|
316
|
+
pagination = headerPagination(headers) ?? undefined;
|
|
317
|
+
}
|
|
318
|
+
freshness =
|
|
319
|
+
(isRecord(body) ? freshnessFromMeta(body.meta) : null) ??
|
|
320
|
+
freshnessFromHeaders(headers);
|
|
321
|
+
}
|
|
322
|
+
const warnings = [...(freshness?.warnings ?? [])];
|
|
323
|
+
if (route === "public" && pagination === undefined) {
|
|
324
|
+
const paged = pageFreeBody(tool.name, data, args);
|
|
325
|
+
if (paged !== null) {
|
|
326
|
+
data = paged.data;
|
|
327
|
+
pagination = paged.pagination;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
if (route === "public" && tool.public_params !== null) {
|
|
331
|
+
const read = new Set([
|
|
332
|
+
...tool.public_params,
|
|
333
|
+
...(KEYLESS_PAGING[tool.name] ? ["limit", "cursor"] : []),
|
|
334
|
+
]);
|
|
335
|
+
const ignored = Object.keys(args).filter((name) => !read.has(name));
|
|
336
|
+
if (ignored.length > 0) {
|
|
337
|
+
warnings.push(`The free route ignores ${ignored.join(", ")}; set an API key (the free tier works) for the v1 route, which reads them.`);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
if (pagination === undefined)
|
|
341
|
+
data = reduceToLatest(tool.name, data, args);
|
|
342
|
+
const capped = capToContext(data);
|
|
343
|
+
const meta = { route, warnings };
|
|
344
|
+
if (freshness !== null) {
|
|
345
|
+
if (freshness.dataset_id !== undefined)
|
|
346
|
+
meta.dataset_id = freshness.dataset_id;
|
|
347
|
+
meta.as_of = freshness.as_of;
|
|
348
|
+
meta.stale_after = freshness.stale_after;
|
|
349
|
+
meta.freshness_status = freshness.freshness_status;
|
|
350
|
+
meta.runtime_status = freshness.runtime_status;
|
|
351
|
+
if (freshness.served_from !== undefined) {
|
|
352
|
+
meta.served_from = freshness.served_from;
|
|
353
|
+
}
|
|
354
|
+
if (freshness.truncated)
|
|
355
|
+
meta.truncated = true;
|
|
356
|
+
}
|
|
357
|
+
if (Object.keys(capped.fields).length > 0) {
|
|
358
|
+
meta.truncated = true;
|
|
359
|
+
meta.truncated_fields = capped.fields;
|
|
360
|
+
meta.truncation_message = TRUNCATION_MESSAGE;
|
|
361
|
+
}
|
|
362
|
+
return {
|
|
363
|
+
data: capped.data,
|
|
364
|
+
...(pagination === undefined ? {} : { pagination }),
|
|
365
|
+
meta,
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
/** Calls an endpoint tool: validated arguments, the route the key picks, the result. */
|
|
369
|
+
export async function callEndpointTool(tool, args, callApi) {
|
|
370
|
+
const prepared = prepareArguments(tool, args);
|
|
371
|
+
const { apiPath, fallbackPath } = toolRoutes(tool);
|
|
372
|
+
const query = queryOf(prepared);
|
|
373
|
+
const answer = callApi.raw
|
|
374
|
+
? await callApi.raw(apiPath, fallbackPath, query)
|
|
375
|
+
: {
|
|
376
|
+
route: "v1",
|
|
377
|
+
body: await callApi(apiPath, fallbackPath, query),
|
|
378
|
+
headers: new Headers(),
|
|
379
|
+
};
|
|
380
|
+
return toolResult(tool, prepared, answer);
|
|
381
|
+
}
|
|
382
|
+
//# sourceMappingURL=endpoint-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endpoint-tools.js","sourceRoot":"","sources":["../src/endpoint-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,GAIjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,QAAQ,GAGT,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,SAAS,EACT,kBAAkB,EAClB,YAAY,EACZ,SAAS,GACV,MAAM,mBAAmB,CAAC;AAE3B,MAAM,CAAC,MAAM,cAAc,GAA4B,QAAQ,CAAC,KAAK,CAAC;AAEtE,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;AAE/E,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,MAAM,IAAI,GAAG,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACrC,IAAI,IAAI,KAAK,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,oBAAoB,IAAI,EAAE,CAAC,CAAC;IACpE,OAAO,IAAI,CAAC;AACd,CAAC;AAED,iGAAiG;AACjG,MAAM,UAAU,UAAU,CAAC,IAAkB;IAI3C,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI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@
|
|
|
2
2
|
* The Sharpe MCP server, independent of transport: the stdio entry point
|
|
3
3
|
* (index.ts) and the hosted Streamable HTTP endpoint (/api/mcp on
|
|
4
4
|
* www.sharpe.ai) both build their server here, so the two cannot drift.
|
|
5
|
+
*
|
|
6
|
+
* Endpoint tools are data (WP-U12): tools/list serves each one's name, title,
|
|
7
|
+
* description and input JSON Schema (and its output schema, when the manifest
|
|
8
|
+
* publishes them) exactly as the synced agent manifest renders them from
|
|
9
|
+
* src/contracts (endpoint-tools.ts), and the Python server serves the same
|
|
10
|
+
* document. The three composite tools format several
|
|
11
|
+
* endpoints into one report and keep their own schemas.
|
|
5
12
|
*/
|
|
6
13
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
14
|
+
import { type CallToolResult, type Tool } from "@modelcontextprotocol/sdk/types.js";
|
|
7
15
|
import type { ApiCaller } from "./api-client.ts";
|
|
8
16
|
export interface SharpeMcpServerOptions {
|
|
9
17
|
/** Performs the API calls: v1 with a key, the free routes without one. */
|
|
@@ -11,5 +19,17 @@ export interface SharpeMcpServerOptions {
|
|
|
11
19
|
/** Reported as serverInfo.version. */
|
|
12
20
|
version: string;
|
|
13
21
|
}
|
|
22
|
+
interface CompositeTool {
|
|
23
|
+
name: string;
|
|
24
|
+
title: string;
|
|
25
|
+
description: string;
|
|
26
|
+
inputSchema: Tool["inputSchema"];
|
|
27
|
+
run: (callApi: ApiCaller, args: Record<string, unknown>) => Promise<CallToolResult>;
|
|
28
|
+
}
|
|
29
|
+
/** The composite tools: several endpoints, one markdown report (U13 serves them as endpoints). */
|
|
30
|
+
export declare const COMPOSITE_TOOLS: readonly CompositeTool[];
|
|
31
|
+
/** tools/list: the endpoint tools as the manifest renders them, then the composites. */
|
|
32
|
+
export declare function listTools(): Tool[];
|
|
14
33
|
export declare function createSharpeMcpServer(options: SharpeMcpServerOptions): McpServer;
|
|
34
|
+
export {};
|
|
15
35
|
//# sourceMappingURL=server.d.ts.map
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,IAAI,EACV,MAAM,oCAAoC,CAAC;AAE5C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AA0BjD,MAAM,WAAW,sBAAsB;IACrC,0EAA0E;IAC1E,OAAO,EAAE,SAAS,CAAC;IACnB,sCAAsC;IACtC,OAAO,EAAE,MAAM,CAAC;CACjB;AAkDD,UAAU,aAAa;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IACjC,GAAG,EAAE,CACH,OAAO,EAAE,SAAS,EAClB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC1B,OAAO,CAAC,cAAc,CAAC,CAAC;CAC9B;AAED,kGAAkG;AAClG,eAAO,MAAM,eAAe,EAAE,SAAS,aAAa,EAwCnD,CAAC;AAIF,wFAAwF;AACxF,wBAAgB,SAAS,IAAI,IAAI,EAAE,CAyBlC;AA0BD,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,sBAAsB,GAC9B,SAAS,CAqNX"}
|