Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/mcp-server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gemini-mcp",
"version": "1.0.0",
"version": "1.0.1",
"type": "module",
"main": "dist/index.js",
"scripts": {
Expand Down
12 changes: 11 additions & 1 deletion packages/mcp-server/src/client/http.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import { createRequire } from 'module';
import JSONBig from 'json-bigint';
import { config } from '../config.js';
import { buildSignedHeaders } from '../auth/signer.js';

const REQUEST_TIMEOUT_MS = 30_000;

const { version: PKG_VERSION } = createRequire(import.meta.url)('../../package.json') as {
version: string;
};
const USER_AGENT = `gemini-mcp/${PKG_VERSION} (node/${process.versions.node})`;

// Precision-preserving JSON parser. The Gemini API emits some numeric fields
// — most notably prediction-market `orderId` — as JSON numbers in the 17–18
// digit range, which exceed JavaScript's `Number.MAX_SAFE_INTEGER` (2^53 − 1,
Expand Down Expand Up @@ -40,6 +46,7 @@ export class GeminiHttpClient {
}
}
const res = await fetch(url.toString(), {
headers: { 'User-Agent': USER_AGENT },
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
});
const text = await res.text();
Expand All @@ -51,7 +58,10 @@ export class GeminiHttpClient {

async authenticatedPost<T>(endpoint: string, body: Record<string, unknown> = {}): Promise<T> {
const fullBody = config.account ? { ...body, account: config.account } : body;
const headers = buildSignedHeaders(endpoint, fullBody, this.apiKey, this.apiSecret);
const headers = {
...buildSignedHeaders(endpoint, fullBody, this.apiKey, this.apiSecret),
'User-Agent': USER_AGENT,
};
const res = await fetch(`${this.baseUrl}${endpoint}`, {
method: 'POST',
headers,
Expand Down
Loading