1+ import { createRequire } from 'module' ;
12import JSONBig from 'json-bigint' ;
23import { config } from '../config.js' ;
34import { buildSignedHeaders } from '../auth/signer.js' ;
45
56const REQUEST_TIMEOUT_MS = 30_000 ;
67
8+ const { version : PKG_VERSION } = createRequire ( import . meta. url ) ( '../../package.json' ) as {
9+ version : string ;
10+ } ;
11+ const USER_AGENT = `gemini-mcp/${ PKG_VERSION } (node/${ process . versions . node } )` ;
12+
713// Precision-preserving JSON parser. The Gemini API emits some numeric fields
814// — most notably prediction-market `orderId` — as JSON numbers in the 17–18
915// digit range, which exceed JavaScript's `Number.MAX_SAFE_INTEGER` (2^53 − 1,
@@ -40,6 +46,7 @@ export class GeminiHttpClient {
4046 }
4147 }
4248 const res = await fetch ( url . toString ( ) , {
49+ headers : { 'User-Agent' : USER_AGENT } ,
4350 signal : AbortSignal . timeout ( REQUEST_TIMEOUT_MS ) ,
4451 } ) ;
4552 const text = await res . text ( ) ;
@@ -51,7 +58,10 @@ export class GeminiHttpClient {
5158
5259 async authenticatedPost < T > ( endpoint : string , body : Record < string , unknown > = { } ) : Promise < T > {
5360 const fullBody = config . account ? { ...body , account : config . account } : body ;
54- const headers = buildSignedHeaders ( endpoint , fullBody , this . apiKey , this . apiSecret ) ;
61+ const headers = {
62+ ...buildSignedHeaders ( endpoint , fullBody , this . apiKey , this . apiSecret ) ,
63+ 'User-Agent' : USER_AGENT ,
64+ } ;
5565 const res = await fetch ( `${ this . baseUrl } ${ endpoint } ` , {
5666 method : 'POST' ,
5767 headers,
0 commit comments