@sharpe-terminal/mcp-server 1.5.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/dist/server.js CHANGED
@@ -2,14 +2,22 @@
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 { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
7
15
  import { z } from "zod/v3";
8
- import { freshnessOf } from "./api-client.js";
9
- import { TOOL_DEFS } from "./tools.js";
10
16
  import { analyzeCoin, marketBriefing, findOpportunities, } from "./composite-tools.js";
17
+ import { MANIFEST } from "./contracts/manifest.js";
18
+ import { ENDPOINT_TOOLS, callEndpointTool, propertyIssue, } from "./endpoint-tools.js";
11
19
  import { FUTURES_CHARTS, EXCHANGES_DATA, NARRATIVE_SLUGS, ECOSYSTEM_SLUGS, } from "./resources.js";
12
- import { API_TOOL_OUTPUT_SCHEMA, READ_ONLY_MARKET_DATA_TOOL_ANNOTATIONS, TEXT_TOOL_OUTPUT_SCHEMA, toTextToolResult, toToolErrorResult, splitPaginated, toToolResult, truncateResponse, withFreshness, } from "./tool-runtime.js";
20
+ import { READ_ONLY_MARKET_DATA_TOOL_ANNOTATIONS, toStructuredToolResult, toTextErrorResult, toTextToolResult, toToolErrorResult, } from "./tool-runtime.js";
13
21
  /** Sent at initialize: how an agent should pick among the 40 tools. */
14
22
  const SERVER_INSTRUCTIONS = [
15
23
  "Sharpe provides crypto derivatives and market data covering funding rates across 32 venues, futures across 10 exchanges, arbitrage, listings, narratives, ecosystems, and news.",
@@ -31,121 +39,153 @@ const SERVER_INSTRUCTIONS = [
31
39
  "get_token_scanner, get_stablecoins and get_derivatives_overview need an API key; every other tool works without one.",
32
40
  "",
33
41
  "Data freshness: current funding rates refresh every 5 minutes; futures datasets refresh every 10 minutes to 6 hours depending on the metric; narrative/ecosystem market data refreshes every 2 hours and mindshare every 12 hours.",
34
- "Each result says how fresh its data is in `data_freshness` (as_of, stale_after, freshness_status, runtime_status, warnings) whenever the API reports it: treat freshness_status `stale` or `unknown` and runtime_status `degraded` as caveats to state, not as current data.",
42
+ "An endpoint tool answers { data, pagination?, meta }: `data` as the API served it, `pagination` when it is one page (pass pagination.cursor back for the next), and `meta` with the answer's freshness (as_of, stale_after, freshness_status, runtime_status) and warnings whenever the API reports them: treat freshness_status `stale` or `unknown` and runtime_status `degraded` as caveats to state, not as current data. meta.truncated_fields names what was cut to fit your context window.",
35
43
  ].join("\n");
36
44
  const COIN_PARAM_SCHEMA = {
37
45
  coin: z.string().describe("Coin ticker (e.g. BTC, ETH, SOL)"),
38
46
  };
39
- function titleFromToolName(name) {
40
- return name
41
- .split("_")
42
- .filter((part) => part !== "get")
43
- .map((part) => part.charAt(0).toUpperCase() + part.slice(1))
44
- .join(" ");
45
- }
46
- export function createSharpeMcpServer(options) {
47
- const { callApi } = options;
48
- const server = new McpServer({ name: "sharpe-mcp-server", version: options.version }, { instructions: SERVER_INSTRUCTIONS });
49
- // Register each endpoint-backed tool from the definitions.
50
- for (const def of TOOL_DEFS) {
51
- const { name, description, schema, apiPath, fallbackPath, prepareArgs, postProcess, } = def;
52
- const hasParams = Object.keys(schema).length > 0;
53
- if (hasParams) {
54
- server.registerTool(name, {
55
- title: titleFromToolName(name),
56
- description,
57
- inputSchema: schema,
58
- outputSchema: API_TOOL_OUTPUT_SCHEMA,
59
- annotations: READ_ONLY_MARKET_DATA_TOOL_ANNOTATIONS,
60
- }, async (args) => {
61
- try {
62
- const typedArgs = args;
63
- const raw = await callApi(apiPath, fallbackPath, prepareArgs ? prepareArgs(typedArgs) : typedArgs);
64
- // Filter and truncate the rows, then reattach pagination (and any
65
- // metadata beside the page) so continuation cursors survive to
66
- // the tool output.
67
- const { rows, pagination, extras } = splitPaginated(raw);
68
- const filtered = postProcess
69
- ? postProcess(rows, typedArgs, { paginated: pagination !== null })
70
- : rows;
71
- const truncated = truncateResponse(filtered);
72
- return toToolResult(withFreshness(pagination
73
- ? { ...extras, data: truncated, pagination }
74
- : truncated, freshnessOf(raw)));
75
- }
76
- catch (err) {
77
- return toToolErrorResult(err);
78
- }
79
- });
80
- }
81
- else {
82
- server.registerTool(name, {
83
- title: titleFromToolName(name),
84
- description,
85
- outputSchema: API_TOOL_OUTPUT_SCHEMA,
86
- annotations: READ_ONLY_MARKET_DATA_TOOL_ANNOTATIONS,
87
- }, async () => {
88
- try {
89
- const raw = await callApi(apiPath, fallbackPath, {});
90
- const { rows, pagination, extras } = splitPaginated(raw);
91
- const filtered = postProcess
92
- ? postProcess(rows, {}, { paginated: pagination !== null })
93
- : rows;
94
- const truncated = truncateResponse(filtered);
95
- return toToolResult(withFreshness(pagination
96
- ? { ...extras, data: truncated, pagination }
97
- : truncated, freshnessOf(raw)));
98
- }
99
- catch (err) {
100
- return toToolErrorResult(err);
101
- }
102
- });
103
- }
104
- }
105
- // ── Composite tools ──────────────────────────────────────────────────
106
- server.registerTool("analyze_coin", {
47
+ const JSON_SCHEMA_DRAFT_7 = "http://json-schema.org/draft-07/schema#";
48
+ /** What a composite answers: its markdown report (and analyze_coin's coin). */
49
+ const COMPOSITE_OUTPUT_SCHEMA = {
50
+ type: "object",
51
+ properties: {
52
+ report: { type: "string", description: "Formatted markdown report." },
53
+ // analyze_coin returns the coin beside its report; leaving it out made SDK
54
+ // clients that validate output reject every analyze_coin result (-32602,
55
+ // 2026-09-26).
56
+ coin: { type: "string", description: "Coin the report covers." },
57
+ error: {
58
+ type: "string",
59
+ description: "Error message when the call fails.",
60
+ },
61
+ },
62
+ additionalProperties: false,
63
+ $schema: JSON_SCHEMA_DRAFT_7,
64
+ };
65
+ /** The composite tools: several endpoints, one markdown report (U13 serves them as endpoints). */
66
+ export const COMPOSITE_TOOLS = [
67
+ {
68
+ name: "analyze_coin",
107
69
  title: "Analyze Coin",
108
70
  description: "Single-coin analysis in one view: funding rates, futures OI, and a deterministic directional score.",
109
- inputSchema: COIN_PARAM_SCHEMA,
110
- outputSchema: TEXT_TOOL_OUTPUT_SCHEMA,
111
- annotations: READ_ONLY_MARKET_DATA_TOOL_ANNOTATIONS,
112
- }, async (args) => {
113
- try {
71
+ inputSchema: {
72
+ type: "object",
73
+ properties: {
74
+ coin: {
75
+ type: "string",
76
+ description: "Coin ticker (e.g. BTC, ETH, SOL)",
77
+ },
78
+ },
79
+ required: ["coin"],
80
+ additionalProperties: false,
81
+ $schema: JSON_SCHEMA_DRAFT_7,
82
+ },
83
+ run: async (callApi, args) => {
114
84
  const coin = typeof args.coin === "string" ? args.coin : "BTC";
115
85
  const text = await analyzeCoin(callApi, coin);
116
86
  return toTextToolResult(text, { coin: coin.toUpperCase() });
117
- }
118
- catch (err) {
119
- return toToolErrorResult(err);
120
- }
121
- });
122
- server.registerTool("market_briefing", {
87
+ },
88
+ },
89
+ {
90
+ name: "market_briefing",
123
91
  title: "Market Briefing",
124
92
  description: "Market briefing with market overview, top narratives, and a funding rate summary.",
125
- outputSchema: TEXT_TOOL_OUTPUT_SCHEMA,
126
- annotations: READ_ONLY_MARKET_DATA_TOOL_ANNOTATIONS,
127
- }, async () => {
128
- try {
129
- const text = await marketBriefing(callApi);
130
- return toTextToolResult(text);
131
- }
132
- catch (err) {
133
- return toToolErrorResult(err);
134
- }
135
- });
136
- server.registerTool("find_opportunities", {
93
+ inputSchema: { type: "object", properties: {} },
94
+ run: async (callApi) => toTextToolResult(await marketBriefing(callApi)),
95
+ },
96
+ {
97
+ name: "find_opportunities",
137
98
  title: "Find Opportunities",
138
99
  description: "Scan all exchanges for the best funding rate arbitrage opportunities across spot-perp basis trades and cross-exchange funding arb.",
139
- outputSchema: TEXT_TOOL_OUTPUT_SCHEMA,
140
- annotations: READ_ONLY_MARKET_DATA_TOOL_ANNOTATIONS,
141
- }, async () => {
142
- try {
143
- const text = await findOpportunities(callApi);
144
- return toTextToolResult(text);
100
+ inputSchema: { type: "object", properties: {} },
101
+ run: async (callApi) => toTextToolResult(await findOpportunities(callApi)),
102
+ },
103
+ ];
104
+ const EXECUTION = { taskSupport: "forbidden" };
105
+ /** tools/list: the endpoint tools as the manifest renders them, then the composites. */
106
+ export function listTools() {
107
+ return [
108
+ ...ENDPOINT_TOOLS.map((tool) => ({
109
+ name: tool.name,
110
+ title: tool.title,
111
+ description: tool.description,
112
+ inputSchema: tool.input_schema,
113
+ // Published only when the manifest says so (PUBLISH_OUTPUT_SCHEMAS in scripts/contracts/agent-manifest.ts):
114
+ // a validating client fails a result that breaks its schema, and v1's are not proven yet.
115
+ ...(MANIFEST.publish_output_schemas
116
+ ? { outputSchema: tool.output_schema }
117
+ : {}),
118
+ annotations: READ_ONLY_MARKET_DATA_TOOL_ANNOTATIONS,
119
+ execution: EXECUTION,
120
+ })),
121
+ ...COMPOSITE_TOOLS.map((tool) => ({
122
+ name: tool.name,
123
+ title: tool.title,
124
+ description: tool.description,
125
+ inputSchema: tool.inputSchema,
126
+ outputSchema: COMPOSITE_OUTPUT_SCHEMA,
127
+ annotations: READ_ONLY_MARKET_DATA_TOOL_ANNOTATIONS,
128
+ execution: EXECUTION,
129
+ })),
130
+ ];
131
+ }
132
+ function compositeInputIssues(tool, args) {
133
+ const properties = (tool.inputSchema.properties ?? {});
134
+ const required = tool.inputSchema.required ?? [];
135
+ const issues = Object.keys(args)
136
+ .filter((name) => !(name in properties))
137
+ .map((name) => `unknown argument "${name}"`);
138
+ for (const [name, schema] of Object.entries(properties)) {
139
+ const value = args[name];
140
+ if (value === undefined || value === null) {
141
+ if (required.includes(name))
142
+ issues.push(`"${name}" is required`);
143
+ continue;
144
+ }
145
+ const issue = propertyIssue(name, value, schema);
146
+ if (issue !== null)
147
+ issues.push(issue);
148
+ }
149
+ return issues;
150
+ }
151
+ export function createSharpeMcpServer(options) {
152
+ const { callApi } = options;
153
+ const server = new McpServer({ name: "sharpe-mcp-server", version: options.version }, { instructions: SERVER_INSTRUCTIONS });
154
+ // ── Tools ─────────────────────────────────────────────────────────────
155
+ // Served from the manifest, so the JSON a client receives is the manifest's,
156
+ // not a re-rendering of it.
157
+ const endpointTools = new Map(ENDPOINT_TOOLS.map((tool) => [tool.name, tool]));
158
+ const compositeTools = new Map(COMPOSITE_TOOLS.map((tool) => [tool.name, tool]));
159
+ const tools = listTools();
160
+ server.server.registerCapabilities({ tools: { listChanged: true } });
161
+ server.server.setRequestHandler(ListToolsRequestSchema, () => ({ tools }));
162
+ server.server.setRequestHandler(CallToolRequestSchema, async (request) => {
163
+ const { name } = request.params;
164
+ const args = (request.params.arguments ?? {});
165
+ const endpointTool = endpointTools.get(name);
166
+ if (endpointTool !== undefined) {
167
+ try {
168
+ const result = await callEndpointTool(endpointTool, args, callApi);
169
+ return toStructuredToolResult(result);
170
+ }
171
+ catch (err) {
172
+ return toTextErrorResult(err);
173
+ }
145
174
  }
146
- catch (err) {
147
- return toToolErrorResult(err);
175
+ const composite = compositeTools.get(name);
176
+ if (composite !== undefined) {
177
+ const issues = compositeInputIssues(composite, args);
178
+ if (issues.length > 0) {
179
+ return toToolErrorResult(new Error(`Invalid arguments for ${name}: ${issues.join("; ")}`));
180
+ }
181
+ try {
182
+ return await composite.run(callApi, args);
183
+ }
184
+ catch (err) {
185
+ return toToolErrorResult(err);
186
+ }
148
187
  }
188
+ return toTextErrorResult(new Error(`Tool ${name} not found`));
149
189
  });
150
190
  // ── Resources ─────────────────────────────────────────────────────────
151
191
  server.registerResource("futures-charts", "sharpe://charts/futures", {
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"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OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -1,68 +1,47 @@
1
1
  import type { ToolAnnotations } from "@modelcontextprotocol/sdk/types.js";
2
2
  import type { ZodRawShapeCompat } from "@modelcontextprotocol/sdk/server/zod-compat.js";
3
- import type { DataFreshness } from "./api-client.ts";
4
3
  export declare const MAX_ITEMS = 200;
5
4
  export declare const CHARACTER_LIMIT = 25000;
6
5
  export declare const READ_ONLY_MARKET_DATA_TOOL_ANNOTATIONS: ToolAnnotations;
7
- export declare const API_TOOL_OUTPUT_SCHEMA: ZodRawShapeCompat;
8
6
  /**
9
- * Splits a client result into rows + pagination. The api-client preserves
10
- * the pagination envelope for paginated endpoints (funding/rates,
11
- * gem-finder/data); filtering and truncation operate on the rows, and the
12
- * pagination block is reattached to the final payload so callers can pass
13
- * the cursor onward. Metadata riding beside a page (a futures chart's
14
- * `chart`/`coverage`/`source`) comes back as `extras` so it is reattached
15
- * too rather than dropped with the envelope.
7
+ * Splits a composite's API answer into rows + pagination. The api-client keeps
8
+ * the pagination envelope of paginated endpoints (funding/rates,
9
+ * gem-finder/data); metadata riding beside a page (a futures chart's
10
+ * `chart`/`coverage`/`source`) comes back as `extras`.
16
11
  */
17
12
  export declare function splitPaginated(result: unknown): {
18
13
  rows: unknown;
19
14
  pagination: unknown | null;
20
15
  extras: Record<string, unknown>;
21
16
  };
22
- /**
23
- * Client-side paging for a free route that ignores limit/cursor and returns
24
- * every row. Mirrors the v1 `paginateData` contract (src/lib/api/response.ts):
25
- * the cursor is the base64url-encoded next offset, so a keyless caller walks
26
- * the same pages an authenticated one would.
27
- */
28
- export declare function paginateRows(rows: unknown[], limit: number, cursor?: string): {
29
- data: unknown[];
30
- pagination: {
31
- cursor: string | null;
32
- has_more: boolean;
33
- total: number;
34
- };
35
- };
36
17
  /**
37
18
  * A row's time in epoch ms, read from the keys the futures routes sort on
38
19
  * (`snapshot_at ?? settled_at ?? timestamp`). Null when absent or unparseable.
39
20
  */
40
21
  export declare function rowTimeMs(row: unknown): number | null;
41
- export declare const TEXT_TOOL_OUTPUT_SCHEMA: ZodRawShapeCompat;
22
+ export declare const TRUNCATION_MESSAGE = "Response truncated to protect the agent context window. Narrow the result set with a cursor, offset, or filter parameters to retrieve the remaining items.";
23
+ /** One cut the client made: `total` items (or characters) received, `showing` kept. */
24
+ export interface TruncatedField {
25
+ total: number;
26
+ showing: number;
27
+ kept?: "latest";
28
+ }
29
+ /** The JSON text an agent receives, and the length the context guard measures (UTF-16 units, as Python counts them). */
30
+ export declare function jsonText(value: unknown): string;
42
31
  /**
43
- * Client-side pagination for the free Gem Finder fallback, whose raw payload
44
- * contains the complete `coins` array. Cursor shape matches the v1 endpoint so
45
- * agents do not silently restart from offset zero when no API key is set.
32
+ * The payload cut to fit the agent's context window, and the cuts: every array to MAX_ITEMS, then, while the JSON
33
+ * is over CHARACTER_LIMIT, the largest array halved (an ascending series from its old end), then the longest string.
34
+ * The payload keeps its shape (the tool's output schema still holds); what was cut is reported beside it, by path
35
+ * from `data`, never inside it.
46
36
  */
47
- export declare function paginateSnapshotPayload(payload: Record<string, unknown>, limit: number, cursor?: string): {
48
- data: unknown[];
49
- pagination: {
50
- cursor: string | null;
51
- has_more: boolean;
52
- total: number;
53
- };
37
+ export declare function capToContext(data: unknown): {
38
+ data: unknown;
39
+ fields: Record<string, TruncatedField>;
54
40
  };
55
- export declare function truncateResponse(data: unknown): unknown;
56
- /**
57
- * The result with the API's freshness envelope beside it (engine L5 WP-S12): an object gains `data_freshness`
58
- * (dataset, `as_of`, `stale_after`, `freshness_status`, `runtime_status`, `warnings`); anything else is wrapped as
59
- * `{ data, data_freshness }`, the shape a paged answer already has. Nothing changes when the API said nothing.
60
- */
61
- export declare function withFreshness(result: unknown, freshness: DataFreshness | null): unknown;
62
- export declare function toToolResult(result: unknown): {
63
- structuredContent: {
64
- result: unknown;
65
- };
41
+ export declare const TEXT_TOOL_OUTPUT_SCHEMA: ZodRawShapeCompat;
42
+ /** An endpoint tool's answer: the result as `structuredContent`, and the same JSON as text for clients without it. */
43
+ export declare function toStructuredToolResult(result: Record<string, unknown>): {
44
+ structuredContent: Record<string, unknown>;
66
45
  content: {
67
46
  type: "text";
68
47
  text: string;
@@ -77,6 +56,7 @@ export declare function toTextToolResult(report: string, extra?: Record<string,
77
56
  text: string;
78
57
  }[];
79
58
  };
59
+ /** A composite's failure: `{ error }` as structured content, and as text. */
80
60
  export declare function toToolErrorResult(error: unknown): {
81
61
  structuredContent: {
82
62
  error: string;
@@ -87,4 +67,12 @@ export declare function toToolErrorResult(error: unknown): {
87
67
  }[];
88
68
  isError: true;
89
69
  };
70
+ /** An endpoint tool's failure: the message, as text (the Python server reports a tool error the same way). */
71
+ export declare function toTextErrorResult(error: unknown): {
72
+ content: {
73
+ type: "text";
74
+ text: string;
75
+ }[];
76
+ isError: true;
77
+ };
90
78
  //# sourceMappingURL=tool-runtime.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tool-runtime.d.ts","sourceRoot":"","sources":["../src/tool-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gDAAgD,CAAC;AAExF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,eAAO,MAAM,SAAS,MAAM,CAAC;AAC7B,eAAO,MAAM,eAAe,QAAQ,CAAC;AAErC,eAAO,MAAM,sCAAsC,EAAE,eAKpD,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAQnB,iBAAiB,CAAC;AAElC;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,OAAO,GAAG;IAC/C,IAAI,EAAE,OAAO,CAAC;IACd,UAAU,EAAE,OAAO,GAAG,IAAI,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC,CAYA;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,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