From 4989fc74a94c6fc9c8874ff07f7d3c551ea699f1 Mon Sep 17 00:00:00 2001 From: Thykof Date: Thu, 26 Feb 2026 14:52:58 +0100 Subject: [PATCH] add 5 minutes polymarket --- .speakeasy/gen.lock | 83 ++++++---- .speakeasy/gen.yaml | 6 +- .speakeasy/in.openapi.yaml | 48 +++++- .speakeasy/out.openapi.yaml | 52 +++++- .speakeasy/workflow.lock | 10 +- manifest.json | 8 +- package-lock.json | 4 +- package.json | 2 +- src/funcs/getInsightsPolymarketUpDown5min.ts | 148 ++++++++++++++++++ src/funcs/getInsightsVolatility.ts | 2 +- src/hooks/hooks.ts | 2 - src/lib/config.ts | 6 +- src/mcp-server/cli/serve/command.ts | 94 +++++++++++ src/mcp-server/cli/serve/impl.ts | 99 ++++++++++++ src/mcp-server/mcp-server.ts | 4 +- src/mcp-server/server.ts | 4 +- .../tools/getInsightsPolymarketUpDown5min.ts | 44 ++++++ src/mcp-server/tools/getInsightsVolatility.ts | 2 +- .../getinsightspolymarketupdown5minop.ts | 45 ++++++ src/tool-names.ts | 6 +- 20 files changed, 617 insertions(+), 52 deletions(-) create mode 100644 src/funcs/getInsightsPolymarketUpDown5min.ts create mode 100644 src/mcp-server/cli/serve/command.ts create mode 100644 src/mcp-server/cli/serve/impl.ts create mode 100644 src/mcp-server/tools/getInsightsPolymarketUpDown5min.ts create mode 100644 src/models/getinsightspolymarketupdown5minop.ts diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index e25c40c..daa431b 100644 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,20 +1,20 @@ lockVersion: 2.0.0 id: aefbfd95-3898-417a-81f2-07292e60b44f management: - docChecksum: 5da4c0f7751345c6f30fdca64240081e + docChecksum: bb938b01745aa618440a4ae62c1c5ed3 docVersion: "1.0" - speakeasyVersion: 1.729.0 - generationVersion: 2.841.0 - releaseVersion: 0.0.14 - configChecksum: 0264342dd357594b63f2e57e988c909c + speakeasyVersion: 1.731.1 + generationVersion: 2.844.3 + releaseVersion: 0.0.15 + configChecksum: 787f56b5014e12901e7fc8ac8c45cb0a persistentEdits: - generation_id: 1356b30a-f3e7-403a-b610-19e28a3e1b8b - pristine_commit_hash: 1c7bd67c76f1fbc3896500744cffab6e67a294ed - pristine_tree_hash: 9e50c27c2c769d8c7dcdbecac1ad294b33414c77 + generation_id: 33ecf448-a2af-4279-8928-646acde0fba5 + pristine_commit_hash: 22bb75c132147fb9565115a1e1d84b09da8905cf + pristine_tree_hash: 2fc836b845674ee1f837d215bfc181f6c9a78cee features: mcp-typescript: additionalDependencies: 0.1.0 - core: 1.2.14 + core: 1.2.15 defaultEnabledRetries: 0.1.0 globalSecurityCallbacks: 0.0.0 globalServerURLs: 0.1.1 @@ -40,12 +40,12 @@ trackedFiles: pristine_git_object: 4f9e60a9462fc4def738d60c3aaadf8232ef185f manifest.json: id: ca642a226869 - last_write_checksum: sha1:a6f8306d7fcec70e38ccb77c476b25e677da64de - pristine_git_object: e306c415838a1bc93288ec90ed7a6e067729b68f + last_write_checksum: sha1:432310374d65e790aa2d6896ab13ac265ce6d61a + pristine_git_object: 522884f7a101218cb25ec58e25626cff26f415ab package.json: id: 7030d0b2f71b - last_write_checksum: sha1:dc645a87b0b7878dba0d6d2eaf014075989976af - pristine_git_object: 81c8dceaa931d31143cd2b73daba60e34e11ba81 + last_write_checksum: sha1:bd3ed46575ac3202829e3d3225c5238776d2789e + pristine_git_object: 6ed566925a7cf6e52b65c216f253c8be90418627 src/core.ts: id: f431fdbcd144 last_write_checksum: sha1:b8bee26e217d2a6cef11b011884a3e6ca4fa471a @@ -74,6 +74,10 @@ trackedFiles: id: 1ee98541cc71 last_write_checksum: sha1:f902360cc4e1805c29eed6c71ea4f355235fd43c pristine_git_object: 1256b5d6968be52861dc3fcfea6b1e7671061589 + src/funcs/getInsightsPolymarketUpDown5min.ts: + id: ce6a8fb24e9f + last_write_checksum: sha1:2ec4bbd1bbc494780fea60d08a4628b70691838e + pristine_git_object: 3831dc1d2af0ba8b8791ce502447a15773774ba4 src/funcs/getInsightsPolymarketUpDownDaily.ts: id: ef191c6656c9 last_write_checksum: sha1:0169d594b4c52e7e8097bad2af7aeacf6cea0437 @@ -88,12 +92,12 @@ trackedFiles: pristine_git_object: 515d6a9d6bf0566f412e7f448c63dc266ca87969 src/funcs/getInsightsVolatility.ts: id: a7a7c9b3a923 - last_write_checksum: sha1:50b1aaa3c7d3f3ce35ccddbf8c562c18e24b891f - pristine_git_object: fa6adce1c48c9d34c2a3d5949f4156f0a8041b82 + last_write_checksum: sha1:280a3489935719cc61bc71d7e672bca31708a083 + pristine_git_object: 8706481331826041a73c3a2e1396582b70eca8cc src/hooks/hooks.ts: id: a2463fc6f69b - last_write_checksum: sha1:36c7bf5c31e0986fba9e0f9db28a769be7904ffd - pristine_git_object: 28c90f854c4e8bba492d873d391ea8d68ca6e009 + last_write_checksum: sha1:07f57b2921d671cc3158934b5f646d5ad3eb6827 + pristine_git_object: bc0fe32856eb2391fa876a7cdb5dae106d39522d src/hooks/types.ts: id: 2a02d86ec24f last_write_checksum: sha1:622c2ac820271766bc4010bfc3904738c4c5ed0f @@ -108,8 +112,8 @@ trackedFiles: pristine_git_object: b45f432798e2151eee7f6eb4df628b7310942c01 src/lib/config.ts: id: 320761608fb3 - last_write_checksum: sha1:1236ecb41cb35430ec7571cfd07310cc929a73bd - pristine_git_object: ea85e8e494069a73b27dd7a84642bc2974fcb03b + last_write_checksum: sha1:a850e2aa69314254bdc96ef456330c43b65231dd + pristine_git_object: 65b38f7d1448dabf29df61ba8097b581a8c68927 src/lib/dlv.ts: id: b1988214835a last_write_checksum: sha1:eaac763b22717206a6199104e0403ed17a4e2711 @@ -174,6 +178,14 @@ trackedFiles: id: 4ade0ef98b00 last_write_checksum: sha1:328ffc5ed0eca56509bf2828264c3b2c87926e09 pristine_git_object: ed4a1808d7da14f0f0bb0cf27cc7eb7414a3182c + src/mcp-server/cli/serve/command.ts: + id: 7cd4394c80e8 + last_write_checksum: sha1:430e5cca78784eea3c4a6f4d873158feef27894e + pristine_git_object: 3fa72520cffb192d50efe846cc6fabdc2b76515f + src/mcp-server/cli/serve/impl.ts: + id: 03e83f226068 + last_write_checksum: sha1:c8f808eb869a150280c433cd45bbd7f287c9d923 + pristine_git_object: 73310ad95fcde4c6ff4747387c87d8ef1f24e5f3 src/mcp-server/cli/start/command.ts: id: b3e53408ccb4 last_write_checksum: sha1:8201bb27d0a8ade03cf07d2428da4bcd4c19de89 @@ -196,8 +208,8 @@ trackedFiles: pristine_git_object: cdc4b29578f38417d67b16a5866460c43c9b81a6 src/mcp-server/mcp-server.ts: id: aabbc4ab07c1 - last_write_checksum: sha1:cf803d4474a87f86b4c69d94a4c30e0671bffe48 - pristine_git_object: a613270081a7e681aff399dafb06a0e7292460b4 + last_write_checksum: sha1:9fd4256cf0a746e018ddb1cb7ffcc050902eedd7 + pristine_git_object: e2aef655d29e6471b8f78681ed2daedff532205b src/mcp-server/prompts.ts: id: 26f3d73cbf31 last_write_checksum: sha1:73fbd9fa7c8c4c8be08b0ae4de74243fb225ce92 @@ -212,8 +224,8 @@ trackedFiles: pristine_git_object: 524b864b4a0d515386ff3f42ed22463827039c06 src/mcp-server/server.ts: id: 2784dd48e82a - last_write_checksum: sha1:518dee05b7468e1580c533f7b724577b2ac98718 - pristine_git_object: f489c91e1340cd26941766e29cd786c0728a05dd + last_write_checksum: sha1:358f4318242beb767abb5d1f84b64ce77ce58aa2 + pristine_git_object: cb814e03b19d947e882557d6e965b924d2962653 src/mcp-server/shared.ts: id: 074e80d4be1e last_write_checksum: sha1:89d816c34ea71049cbf484f9704239e5372858f1 @@ -246,6 +258,10 @@ trackedFiles: id: c2d9a15e728e last_write_checksum: sha1:ab9e24e49dc0af839518dc10d0a883908273e65e pristine_git_object: 800578275b3eef85cb02210179dc33ffa4816e5e + src/mcp-server/tools/getInsightsPolymarketUpDown5min.ts: + id: 54db83170089 + last_write_checksum: sha1:58e93b980a1bd138750470861f764924c52d3436 + pristine_git_object: 4a92c42b1c9de63aab92e463edbdb79205d3dc2c src/mcp-server/tools/getInsightsPolymarketUpDownDaily.ts: id: 68d48f874d49 last_write_checksum: sha1:229697151ccc8ef91ffb4c39dbacf3fea5d4676b @@ -260,8 +276,8 @@ trackedFiles: pristine_git_object: 5be46effc09f6353c5cea485e93eeab58e59b441 src/mcp-server/tools/getInsightsVolatility.ts: id: 236e430e069f - last_write_checksum: sha1:1fe5c7aa0ddcda5ae842eb1aaa53ff863d95e842 - pristine_git_object: bf143a26f1aab14afa3b899b1ef2a7574a88919e + last_write_checksum: sha1:377e060a9607fdfc13cf89af0be968d221ee24d1 + pristine_git_object: b09cdc76b40e1cf7f9efccfb2796668ca4bd4900 src/models/errors/apierror.ts: id: e2280e075454 last_write_checksum: sha1:b6927c28c3304c3afffb374d0b20e865c6bab933 @@ -298,6 +314,10 @@ trackedFiles: id: 9365856ae697 last_write_checksum: sha1:6932ae63a19f9b3d71d55521fdec2748c5748f21 pristine_git_object: 1c85c21a7a35c60f956cc1d3a705a8128e86cb13 + src/models/getinsightspolymarketupdown5minop.ts: + id: f10f599e30d8 + last_write_checksum: sha1:4d97112c4103707c45a478e456087d90bc91a590 + pristine_git_object: cdd8d1630fe99b041ec40fc05bb74871b7ff462a src/models/getinsightspolymarketupdowndailyop.ts: id: 9454a94e059e last_write_checksum: sha1:474ff554b7f282978d37a759f057a5be93207b1f @@ -396,8 +416,8 @@ trackedFiles: pristine_git_object: 73a5f25764717694174216fd4734c72ab2a3fff1 src/tool-names.ts: id: a9977280f9eb - last_write_checksum: sha1:ca78fad504e501d2f098b04a643eb0145c5dd35e - pristine_git_object: eaf7c7595022ccf4aa76f1a8405cc22a88d64e08 + last_write_checksum: sha1:12c69db74e625acc47db07f965abb2af2e8ebc2a + pristine_git_object: 4415c34c4d542482006eb094594b073f1920e4b9 src/types/async.ts: id: fac8da972f86 last_write_checksum: sha1:e2a7c53b428567587741f38e6da489f596de6227 @@ -648,4 +668,13 @@ examples: application/json: "" "500": application/json: "" + get_/insights/polymarket/up-down/5min: + speakeasy-default-get-/insights/polymarket/up-down/5min: + responses: + "200": + application/json: {} + "400": + application/json: "" + "500": + application/json: "" examplesVersion: 1.0.2 diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index 5892a56..8b0e383 100644 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -16,8 +16,8 @@ generation: sharedNestedComponentsJan2026: true nameOverrideFeb2026: false auth: - oAuth2ClientCredentialsEnabled: true - oAuth2PasswordEnabled: true + oAuth2ClientCredentialsEnabled: false + oAuth2PasswordEnabled: false hoistGlobalSecurity: true inferSSEOverload: true sdkHooksConfigAccess: true @@ -32,7 +32,7 @@ generation: generateNewTests: true skipResponseBodyAssertions: false mcp-typescript: - version: 0.0.14 + version: 0.0.15 additionalDependencies: dependencies: {} devDependencies: {} diff --git a/.speakeasy/in.openapi.yaml b/.speakeasy/in.openapi.yaml index 577d1ee..194814b 100644 --- a/.speakeasy/in.openapi.yaml +++ b/.speakeasy/in.openapi.yaml @@ -556,6 +556,52 @@ paths: schema: type: string summary: Insight - Polymarket price range + /insights/polymarket/up-down/5min: + get: + description: "Get SynthData's estimated fair probabilities alongside live Polymarket odds for 5 minutes Up/Down contracts. Returns both synth and Polymarket probabilities, current outcome, and order book data (best bid/ask). Compare to identify mispriced bets on shorter timeframes. Supported assets: BTC, ETH, SOL." + parameters: + - description: "Symbol of the asset: BTC, ETH, SOL" + example: BTC + in: query + name: asset + type: string + - description: "Forecast horizon: 1h for next-hour or 24h for next-day price intervals (default: 1h)" + example: 1h + in: query + name: horizon + type: string + - description: Number of days to aggregate for the meta-leaderboard (default is 14). See 'Leaderboard - Latest Meta-Leaderboard'. + example: 14 + in: query + name: days + type: integer + - description: Number of miners from the meta-leaderboard to use for the analysis (default is 10) + example: 10 + in: query + name: limit + type: integer + - description: API key + example: Apikey MY_API_KEY + in: header + name: Authorization + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: "#/definitions/types.PolymarketUpDownResponse" + "400": + description: Bad Request + schema: + type: string + "500": + description: Internal Server Error + schema: + type: string + summary: Insight - Polymarket up/down 5 minutes /insights/polymarket/up-down/15min: get: description: "Get SynthData's estimated fair probabilities alongside live Polymarket odds for 15 minutes Up/Down contracts. Returns both synth and Polymarket probabilities, current outcome, and order book data (best bid/ask). Compare to identify mispriced bets on shorter timeframes. Supported assets: BTC, ETH, SOL." @@ -742,7 +788,7 @@ paths: summary: Prediction Percentiles - meta model from top 10 miners /insights/volatility: get: - description: It selects the top 'limit' miners from the meta-leaderboard to calculate the volatility. + description: Get SynthData's volatility forecasts for an asset. Returns expected volatility over the next 24 hours, along with historical realized volatility. parameters: - description: "Symbol of the asset: BTC, ETH, XAU, SOL, JITOSOL, SPY, NVDA, GOOGL, TSLA, AAPL" example: BTC diff --git a/.speakeasy/out.openapi.yaml b/.speakeasy/out.openapi.yaml index 7b94dd6..7c1eab2 100644 --- a/.speakeasy/out.openapi.yaml +++ b/.speakeasy/out.openapi.yaml @@ -308,6 +308,56 @@ paths: application/json: schema: type: string + /insights/polymarket/up-down/5min: + get: + summary: Insight - Polymarket up/down 5 minutes + description: 'Get SynthData''s estimated fair probabilities alongside live Polymarket odds for 5 minutes Up/Down contracts. Returns both synth and Polymarket probabilities, current outcome, and order book data (best bid/ask). Compare to identify mispriced bets on shorter timeframes. Supported assets: BTC, ETH, SOL.' + parameters: + - name: asset + in: query + description: 'Symbol of the asset: BTC, ETH, SOL' + schema: + type: string + - name: horizon + in: query + description: 'Forecast horizon: 1h for next-hour or 24h for next-day price intervals (default: 1h)' + schema: + type: string + - name: days + in: query + description: Number of days to aggregate for the meta-leaderboard (default is 14). See 'Leaderboard - Latest Meta-Leaderboard'. + schema: + type: integer + - name: limit + in: query + description: Number of miners from the meta-leaderboard to use for the analysis (default is 10) + schema: + type: integer + - name: Authorization + in: header + description: API key + required: true + schema: + type: string + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/types.PolymarketUpDownResponse' + "400": + description: Bad Request + content: + application/json: + schema: + type: string + "500": + description: Internal Server Error + content: + application/json: + schema: + type: string /insights/polymarket/up-down/daily: get: summary: Insight - Polymarket up/down daily @@ -461,7 +511,7 @@ paths: /insights/volatility: get: summary: Insight - Volatility - description: It selects the top 'limit' miners from the meta-leaderboard to calculate the volatility. + description: Get SynthData's volatility forecasts for an asset. Returns expected volatility over the next 24 hours, along with historical realized volatility. parameters: - name: asset in: query diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index edfa22f..9c51734 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -1,9 +1,9 @@ -speakeasyVersion: 1.729.0 +speakeasyVersion: 1.731.1 sources: Synth API: sourceNamespace: synth-mcp - sourceRevisionDigest: sha256:3e60bef4d3e90d5ee3579540d1681cce1bab80170510cfed4b2b4300849d157b - sourceBlobDigest: sha256:a9598e501b2bd94d9fc33c522ba7da448de26ff3fe265a99ad887fdeb90a887c + sourceRevisionDigest: sha256:eb3c2c782316b353fa767f354d3768d4f00aaa1a070ba0d99bb56ab9a42cfb04 + sourceBlobDigest: sha256:c643d2726330c899aa2d17d6e6320fd96e8373472eb0dc62bd7323b68bb00820 tags: - latest - "1.0" @@ -11,8 +11,8 @@ targets: synth: source: Synth API sourceNamespace: synth-mcp - sourceRevisionDigest: sha256:3e60bef4d3e90d5ee3579540d1681cce1bab80170510cfed4b2b4300849d157b - sourceBlobDigest: sha256:a9598e501b2bd94d9fc33c522ba7da448de26ff3fe265a99ad887fdeb90a887c + sourceRevisionDigest: sha256:eb3c2c782316b353fa767f354d3768d4f00aaa1a070ba0d99bb56ab9a42cfb04 + sourceBlobDigest: sha256:c643d2726330c899aa2d17d6e6320fd96e8373472eb0dc62bd7323b68bb00820 workflow: workflowVersion: 1.0.0 speakeasyVersion: latest diff --git a/manifest.json b/manifest.json index acb973c..4f699c0 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": "0.3", "name": "synth-mcp", - "version": "0.0.14", + "version": "0.0.15", "description": "", "long_description": "Synth: Synth API offers programmatic access to probabilistic price forecasts for Equities, Commodities and Cryptocurrencies.", "author": { @@ -70,6 +70,10 @@ "name": "get-insights-polymarket-up-down-15min", "description": "Insight - Polymarket up/down 15 minutes\n\nGet SynthData's estimated fair probabilities alongside live Polymarket odds for 15 minutes Up/Down contracts. Returns both synth and Polymarket probabilities, current outcome, and order book data (best bid/ask). Compare to identify mispriced bets on shorter timeframes. Supported assets: BTC, ETH, SOL." }, + { + "name": "get-insights-polymarket-up-down-5min", + "description": "Insight - Polymarket up/down 5 minutes\n\nGet SynthData's estimated fair probabilities alongside live Polymarket odds for 5 minutes Up/Down contracts. Returns both synth and Polymarket probabilities, current outcome, and order book data (best bid/ask). Compare to identify mispriced bets on shorter timeframes. Supported assets: BTC, ETH, SOL." + }, { "name": "get-insights-polymarket-up-down-daily", "description": "Insight - Polymarket up/down daily\n\nGet SynthData's estimated fair probabilities alongside live Polymarket odds for daily Up/Down contracts. Returns both synth and Polymarket probabilities, current outcome, and order book data (best bid/ask). Compare to identify mispriced bets. Supported assets: BTC, ETH, XAU, SOL, SPY, NVDA, GOOGL, TSLA, AAPL." @@ -84,7 +88,7 @@ }, { "name": "get-insights-volatility", - "description": "Insight - Volatility\n\nIt selects the top 'limit' miners from the meta-leaderboard to calculate the volatility." + "description": "Insight - Volatility\n\nGet SynthData's volatility forecasts for an asset. Returns expected volatility over the next 24 hours, along with historical realized volatility." } ] } \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 841471d..8921ed5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@mode-network/synth-mcp", - "version": "0.0.14", + "version": "0.0.15", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@mode-network/synth-mcp", - "version": "0.0.14", + "version": "0.0.15", "dependencies": { "@modelcontextprotocol/sdk": "1.26.0", "@stricli/core": "^1.1.2", diff --git a/package.json b/package.json index 2df69d4..308d8c0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mode-network/synth-mcp", - "version": "0.0.14", + "version": "0.0.15", "author": "Synth", "repository": { "type": "git", diff --git a/src/funcs/getInsightsPolymarketUpDown5min.ts b/src/funcs/getInsightsPolymarketUpDown5min.ts new file mode 100644 index 0000000..3831dc1 --- /dev/null +++ b/src/funcs/getInsightsPolymarketUpDown5min.ts @@ -0,0 +1,148 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + * @generated-id: ce6a8fb24e9f + */ + +import { SynthCore } from "../core.js"; +import { encodeFormQuery } from "../lib/encodings.js"; +import { compactMap } from "../lib/primitives.js"; +import { safeParse } from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { pathToFunc } from "../lib/url.js"; +import { APIError } from "../models/errors/apierror.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../models/errors/httpclienterrors.js"; +import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; +import { + GetInsightsPolymarketUpDown5minRequest, + GetInsightsPolymarketUpDown5minRequest$zodSchema, +} from "../models/getinsightspolymarketupdown5minop.js"; +import { APICall, APIPromise } from "../types/async.js"; +import { Result } from "../types/fp.js"; + +/** + * Insight - Polymarket up/down 5 minutes + * + * @remarks + * Get SynthData's estimated fair probabilities alongside live Polymarket odds for 5 minutes Up/Down contracts. Returns both synth and Polymarket probabilities, current outcome, and order book data (best bid/ask). Compare to identify mispriced bets on shorter timeframes. Supported assets: BTC, ETH, SOL. + */ +export function getInsightsPolymarketUpDown5min( + client$: SynthCore, + request?: GetInsightsPolymarketUpDown5minRequest | undefined, + options?: RequestOptions, +): APIPromise< + Result< + Response, + | APIError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + return new APIPromise($do( + client$, + request, + options, + )); +} + +async function $do( + client$: SynthCore, + request?: GetInsightsPolymarketUpDown5minRequest | undefined, + options?: RequestOptions, +): Promise< + [ + Result< + Response, + | APIError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >, + APICall, + ] +> { + const parsed$ = safeParse( + request, + (value$) => + GetInsightsPolymarketUpDown5minRequest$zodSchema.optional().parse(value$), + "Input validation failed", + ); + if (!parsed$.ok) { + return [parsed$, { status: "invalid" }]; + } + const payload$ = parsed$.value; + const body$ = null; + const path$ = pathToFunc("/insights/polymarket/up-down/5min")(); + const query$ = encodeFormQuery({ + "asset": payload$?.asset, + "days": payload$?.days, + "horizon": payload$?.horizon, + "limit": payload$?.limit, + }); + + const headers$ = new Headers(compactMap({ + Accept: "application/json", + })); + + const context = { + options: client$._options, + baseURL: options?.serverURL ?? client$._baseURL ?? "", + operationID: "get_/insights/polymarket/up-down/5min", + oAuth2Scopes: null, + resolvedSecurity: null, + securitySource: null, + retryConfig: options?.retries + || client$._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || [ + "429", + "500", + "502", + "503", + "504", + ], + }; + + const requestRes = client$._createRequest(context, { + method: "GET", + baseURL: options?.serverURL, + path: path$, + headers: headers$, + query: query$, + body: body$, + userAgent: client$._options.userAgent, + timeoutMs: options?.timeoutMs || client$._options.timeoutMs + || -1, + }, options); + if (!requestRes.ok) { + return [requestRes, { status: "invalid" }]; + } + const req$ = requestRes.value; + + const doResult = await client$._do(req$, { + context, + errorCodes: [], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, + }); + if (!doResult.ok) { + return [doResult, { status: "request-error", request: req$ }]; + } + return [doResult, { + status: "complete", + "request": req$, + response: doResult.value, + }]; +} diff --git a/src/funcs/getInsightsVolatility.ts b/src/funcs/getInsightsVolatility.ts index fa6adce..8706481 100644 --- a/src/funcs/getInsightsVolatility.ts +++ b/src/funcs/getInsightsVolatility.ts @@ -29,7 +29,7 @@ import { Result } from "../types/fp.js"; * Insight - Volatility * * @remarks - * It selects the top 'limit' miners from the meta-leaderboard to calculate the volatility. + * Get SynthData's volatility forecasts for an asset. Returns expected volatility over the next 24 hours, along with historical realized volatility. */ export function getInsightsVolatility( client$: SynthCore, diff --git a/src/hooks/hooks.ts b/src/hooks/hooks.ts index 28c90f8..bc0fe32 100644 --- a/src/hooks/hooks.ts +++ b/src/hooks/hooks.ts @@ -3,7 +3,6 @@ * @generated-id: a2463fc6f69b */ -import { initHooks } from "./registration.js"; import { AfterErrorContext, AfterErrorHook, @@ -48,7 +47,6 @@ export class SDKHooks implements Hooks { this.registerAfterErrorHook(hook); } } - initHooks(this); } registerSDKInitHook(hook: SDKInitHook) { diff --git a/src/lib/config.ts b/src/lib/config.ts index ea85e8e..65b38f7 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -57,7 +57,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null { export const SDK_METADATA = { language: "typescript", openapiDocVersion: "1.0", - sdkVersion: "0.0.14", - genVersion: "2.841.0", - userAgent: "speakeasy-sdk/mcp-typescript 0.0.14 2.841.0 1.0 synth-mcp", + sdkVersion: "0.0.15", + genVersion: "2.844.3", + userAgent: "speakeasy-sdk/mcp-typescript 0.0.15 2.844.3 1.0 synth-mcp", } as const; diff --git a/src/mcp-server/cli/serve/command.ts b/src/mcp-server/cli/serve/command.ts new file mode 100644 index 0000000..3fa7252 --- /dev/null +++ b/src/mcp-server/cli/serve/command.ts @@ -0,0 +1,94 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + * @generated-id: 7cd4394c80e8 + */ + +import { buildCommand } from "@stricli/core"; +import { numberParser } from "@stricli/core"; +import * as z from "zod"; +import { consoleLoggerLevels } from "../../console-logger.js"; + +export const serveCommand = buildCommand({ + loader: async () => { + const { main } = await import("./impl.js"); + return main; + }, + parameters: { + flags: { + port: { + kind: "parsed", + brief: "The port to listen on for Streamable HTTP connections", + default: "2718", + parse: (val: string) => + z.coerce.number().int().gte(0).lt(65536).parse(val), + }, + "disable-static-auth": { + kind: "boolean", + brief: + "Disable static authentication, allowing credentials to be passed via request headers only", + default: false, + }, + tool: { + kind: "parsed", + brief: "Specify tools to mount on the server", + optional: true, + variadic: true, + parse: (value) => { + return z.string().parse(value); + }, + }, + mode: { + kind: "enum", + brief: + "Server mode (dynamic: expose list_tools, describe_tool, and execute_tool instead of individual tools)", + values: ["dynamic"], + optional: true, + }, + "server-url": { + kind: "parsed", + brief: "Overrides the default server URL used by the SDK", + optional: false, + parse: (value) => new URL(value).toString(), + }, + "server-index": { + kind: "parsed", + brief: "Selects a predefined server used by the SDK", + optional: true, + parse: numberParser, + }, + "log-level": { + kind: "enum", + brief: "The log level to use for the server", + default: "info", + values: consoleLoggerLevels, + }, + env: { + kind: "parsed", + brief: "Environment variables made available to the server", + optional: true, + variadic: true, + parse: (val: string) => { + const sepIdx = val.indexOf("="); + if (sepIdx === -1) { + throw new Error("Invalid environment variable format"); + } + + const key = val.slice(0, sepIdx); + const value = val.slice(sepIdx + 1); + + return [ + z.string().nonempty({ + message: "Environment variable key must be a non-empty string", + }).parse(key), + z.string().nonempty({ + message: "Environment variable value must be a non-empty string", + }).parse(value), + ] satisfies [string, string]; + }, + }, + }, + }, + docs: { + brief: "Run the MCP server with Streamable HTTP transport", + }, +}); diff --git a/src/mcp-server/cli/serve/impl.ts b/src/mcp-server/cli/serve/impl.ts new file mode 100644 index 0000000..73310ad --- /dev/null +++ b/src/mcp-server/cli/serve/impl.ts @@ -0,0 +1,99 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + * @generated-id: 03e83f226068 + */ + +import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js"; +import type { Transport } from "@modelcontextprotocol/sdk/shared/transport.js"; +import express from "express"; +import { LocalContext } from "../../cli.js"; +import { + ConsoleLoggerLevel, + createConsoleLogger, +} from "../../console-logger.js"; +import { MCPServerFlags } from "../../flags.js"; +import { createMCPServer } from "../../server.js"; + +import { landingPageExpress } from "../../../landing-page.js"; + +interface ServeCommandFlags extends MCPServerFlags { + readonly port: number; + readonly "disable-static-auth": boolean; + readonly "log-level": ConsoleLoggerLevel; + readonly env?: [string, string][]; +} + +export async function main(this: LocalContext, flags: ServeCommandFlags) { + flags.env?.forEach(([key, value]) => { + process.env[key] = value; + }); + + await startStreamableHTTP(flags); +} + +async function startStreamableHTTP(cliFlags: ServeCommandFlags) { + const logger = createConsoleLogger(cliFlags["log-level"]); + const app = express(); + + // Enable CORS for cross-origin requests + app.use((req, res, next) => { + res.header("Access-Control-Allow-Origin", "*"); + res.header("Access-Control-Allow-Methods", "GET, POST, OPTIONS"); + res.header("Access-Control-Allow-Headers", "Content-Type, *"); + if (req.method === "OPTIONS") { + res.sendStatus(204); + return; + } + next(); + }); + + app.use(express.json()); + + app.post("/mcp", async (req, res) => { + const transport = new StreamableHTTPServerTransport({}); + + const { server: mcpServer } = createMCPServer({ + logger, + allowedTools: cliFlags.tool, + dynamic: cliFlags.mode === "dynamic", + serverURL: cliFlags["server-url"], + serverIdx: cliFlags["server-index"], + }); + + mcpServer.server.onerror = (error) => { + logger.error("MCP protocol error", { + error: error instanceof Error ? error.message : String(error), + stack: error instanceof Error ? error.stack : undefined, + }); + }; + + await mcpServer.connect(transport as Transport); + await transport.handleRequest(req, res, req.body); + }); + + app.get("/", landingPageExpress); + + const httpServer = app.listen(cliFlags.port, "0.0.0.0", () => { + const ha = httpServer.address(); + const host = typeof ha === "string" ? ha : `${ha?.address}:${ha?.port}`; + logger.info("MCP Streamable HTTP server started", { host }); + }); + + const shutdown = () => { + logger.info("Shutting down HTTP server"); + + const timer = setTimeout(() => { + logger.info("Forcing shutdown"); + process.exit(1); + }, 5000); + + httpServer.close(() => { + clearTimeout(timer); + logger.info("Graceful shutdown complete"); + process.exit(0); + }); + }; + + process.on("SIGTERM", shutdown); + process.on("SIGINT", shutdown); +} diff --git a/src/mcp-server/mcp-server.ts b/src/mcp-server/mcp-server.ts index a613270..e2aef65 100644 --- a/src/mcp-server/mcp-server.ts +++ b/src/mcp-server/mcp-server.ts @@ -6,11 +6,13 @@ import { buildApplication, buildRouteMap, run } from "@stricli/core"; import process from "node:process"; import { buildContext } from "./cli.js"; +import { serveCommand } from "./cli/serve/command.js"; import { startCommand } from "./cli/start/command.js"; const routes = buildRouteMap({ routes: { start: startCommand, + serve: serveCommand, }, docs: { brief: "MCP server CLI", @@ -20,7 +22,7 @@ const routes = buildRouteMap({ export const app = buildApplication(routes, { name: "mcp", versionInfo: { - currentVersion: "0.0.14", + currentVersion: "0.0.15", }, }); diff --git a/src/mcp-server/server.ts b/src/mcp-server/server.ts index f489c91..cb814e0 100644 --- a/src/mcp-server/server.ts +++ b/src/mcp-server/server.ts @@ -20,6 +20,7 @@ import { tool$getInsightsLpProbabilities } from "./tools/getInsightsLpProbabilit import { tool$getInsightsOptionPricing } from "./tools/getInsightsOptionPricing.js"; import { tool$getInsightsPolymarketRange } from "./tools/getInsightsPolymarketRange.js"; import { tool$getInsightsPolymarketUpDown15min } from "./tools/getInsightsPolymarketUpDown15min.js"; +import { tool$getInsightsPolymarketUpDown5min } from "./tools/getInsightsPolymarketUpDown5min.js"; import { tool$getInsightsPolymarketUpDownDaily } from "./tools/getInsightsPolymarketUpDownDaily.js"; import { tool$getInsightsPolymarketUpDownHourly } from "./tools/getInsightsPolymarketUpDownHourly.js"; import { tool$getInsightsPredictionPercentiles } from "./tools/getInsightsPredictionPercentiles.js"; @@ -36,7 +37,7 @@ export function createMCPServer(deps: { }) { const server = new McpServer({ name: "Synth", - version: "0.0.14", + version: "0.0.15", }); const getClient = deps.getSDK || (() => @@ -85,6 +86,7 @@ export function createMCPServer(deps: { tool(tool$getInsightsOptionPricing); tool(tool$getInsightsPolymarketRange); tool(tool$getInsightsPolymarketUpDown15min); + tool(tool$getInsightsPolymarketUpDown5min); tool(tool$getInsightsPolymarketUpDownDaily); tool(tool$getInsightsPolymarketUpDownHourly); tool(tool$getInsightsPredictionPercentiles); diff --git a/src/mcp-server/tools/getInsightsPolymarketUpDown5min.ts b/src/mcp-server/tools/getInsightsPolymarketUpDown5min.ts new file mode 100644 index 0000000..4a92c42 --- /dev/null +++ b/src/mcp-server/tools/getInsightsPolymarketUpDown5min.ts @@ -0,0 +1,44 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + * @generated-id: 54db83170089 + */ + +import { getInsightsPolymarketUpDown5min } from "../../funcs/getInsightsPolymarketUpDown5min.js"; +import { GetInsightsPolymarketUpDown5minRequest$zodSchema } from "../../models/getinsightspolymarketupdown5minop.js"; +import { formatResult, ToolDefinition } from "../tools.js"; + +const args = { + request: GetInsightsPolymarketUpDown5minRequest$zodSchema.optional(), +}; + +export const tool$getInsightsPolymarketUpDown5min: ToolDefinition = + { + name: "get-insights-polymarket-up-down-5min", + description: `Insight - Polymarket up/down 5 minutes + +Get SynthData's estimated fair probabilities alongside live Polymarket odds for 5 minutes Up/Down contracts. Returns both synth and Polymarket probabilities, current outcome, and order book data (best bid/ask). Compare to identify mispriced bets on shorter timeframes. Supported assets: BTC, ETH, SOL.`, + annotations: { + "title": "", + "destructiveHint": false, + "idempotentHint": false, + "openWorldHint": false, + "readOnlyHint": true, + }, + args, + tool: async (client, args, ctx) => { + const [result] = await getInsightsPolymarketUpDown5min( + client, + args.request, + { fetchOptions: { signal: ctx.signal } }, + ).$inspect(); + + if (!result.ok) { + return { + content: [{ type: "text", text: result.error.message }], + isError: true, + }; + } + + return formatResult(result.value); + }, + }; diff --git a/src/mcp-server/tools/getInsightsVolatility.ts b/src/mcp-server/tools/getInsightsVolatility.ts index bf143a2..b09cdc7 100644 --- a/src/mcp-server/tools/getInsightsVolatility.ts +++ b/src/mcp-server/tools/getInsightsVolatility.ts @@ -15,7 +15,7 @@ export const tool$getInsightsVolatility: ToolDefinition = { name: "get-insights-volatility", description: `Insight - Volatility -It selects the top 'limit' miners from the meta-leaderboard to calculate the volatility.`, +Get SynthData's volatility forecasts for an asset. Returns expected volatility over the next 24 hours, along with historical realized volatility.`, annotations: { "title": "", "destructiveHint": false, diff --git a/src/models/getinsightspolymarketupdown5minop.ts b/src/models/getinsightspolymarketupdown5minop.ts new file mode 100644 index 0000000..cdd8d16 --- /dev/null +++ b/src/models/getinsightspolymarketupdown5minop.ts @@ -0,0 +1,45 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + * @generated-id: f10f599e30d8 + */ + +import * as z from "zod"; +import { + TypesPolymarketUpDownResponse, + TypesPolymarketUpDownResponse$zodSchema, +} from "./typespolymarketupdownresponse.js"; + +export type GetInsightsPolymarketUpDown5minRequest = { + asset?: string | undefined; + horizon?: string | undefined; + days?: number | undefined; + limit?: number | undefined; +}; + +export const GetInsightsPolymarketUpDown5minRequest$zodSchema: z.ZodType< + GetInsightsPolymarketUpDown5minRequest +> = z.object({ + asset: z.string().describe("Symbol of the asset: BTC, ETH, SOL").optional(), + days: z.int().describe( + "Number of days to aggregate for the meta-leaderboard (default is 14). See 'Leaderboard - Latest Meta-Leaderboard'.", + ).optional(), + horizon: z.string().describe( + "Forecast horizon: 1h for next-hour or 24h for next-day price intervals (default: 1h)", + ).optional(), + limit: z.int().describe( + "Number of miners from the meta-leaderboard to use for the analysis (default is 10)", + ).optional(), +}); + +export type GetInsightsPolymarketUpDown5minResponse = + | TypesPolymarketUpDownResponse + | string + | string; + +export const GetInsightsPolymarketUpDown5minResponse$zodSchema: z.ZodType< + GetInsightsPolymarketUpDown5minResponse +> = z.union([ + TypesPolymarketUpDownResponse$zodSchema, + z.string().describe("Bad Request"), + z.string().describe("Internal Server Error"), +]); diff --git a/src/tool-names.ts b/src/tool-names.ts index eaf7c75..4415c34 100644 --- a/src/tool-names.ts +++ b/src/tool-names.ts @@ -24,6 +24,10 @@ export const toolNames: Array<{ name: string; description: string }>= [ "name": "get-insights-polymarket-up-down-15min", "description": "Insight - Polymarket up/down 15 minutes\n\nGet SynthData's estimated fair probabilities alongside live Polymarket odds for 15 minutes Up/Down contracts. Returns both synth and Polymarket probabilities, current outcome, and order book data (best bid/ask). Compare to identify mispriced bets on shorter timeframes. Supported assets: BTC, ETH, SOL." }, + { + "name": "get-insights-polymarket-up-down-5min", + "description": "Insight - Polymarket up/down 5 minutes\n\nGet SynthData's estimated fair probabilities alongside live Polymarket odds for 5 minutes Up/Down contracts. Returns both synth and Polymarket probabilities, current outcome, and order book data (best bid/ask). Compare to identify mispriced bets on shorter timeframes. Supported assets: BTC, ETH, SOL." + }, { "name": "get-insights-polymarket-up-down-daily", "description": "Insight - Polymarket up/down daily\n\nGet SynthData's estimated fair probabilities alongside live Polymarket odds for daily Up/Down contracts. Returns both synth and Polymarket probabilities, current outcome, and order book data (best bid/ask). Compare to identify mispriced bets. Supported assets: BTC, ETH, XAU, SOL, SPY, NVDA, GOOGL, TSLA, AAPL." @@ -38,6 +42,6 @@ export const toolNames: Array<{ name: string; description: string }>= [ }, { "name": "get-insights-volatility", - "description": "Insight - Volatility\n\nIt selects the top 'limit' miners from the meta-leaderboard to calculate the volatility." + "description": "Insight - Volatility\n\nGet SynthData's volatility forecasts for an asset. Returns expected volatility over the next 24 hours, along with historical realized volatility." } ];