@openephemeris/mcp-server 3.2.6 → 3.2.7

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.
@@ -256,6 +256,10 @@ export class BackendClient {
256
256
  if (status >= 500)
257
257
  return new BackendError(`Backend error (${status}): ${msg}`, status, "server_error", true);
258
258
  }
259
+ // Explicit timeout or abort interception
260
+ if (error.code === "ECONNABORTED" || error.code === "ETIMEDOUT") {
261
+ return new BackendError(`The computation took too long and timed out. This usually happens when requesting a massive date range (like 20+ years of transits) or an overly complex query. Please narrow your request and try again.`, 408, "timeout", false);
262
+ }
259
263
  return new BackendError(`Network error: ${error.message}`, 0, "network_error", true);
260
264
  }
261
265
  async get(path, params, timeoutMs) {
package/dist/src/index.js CHANGED
@@ -99,19 +99,44 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
99
99
  if (!tool) {
100
100
  throw new Error(`Unknown tool: ${toolName}`);
101
101
  }
102
+ const startTime = Date.now();
103
+ console.error(`[MCP] Executing tool: ${toolName}`);
102
104
  try {
103
105
  const result = await tool.handler(request.params.arguments ?? {});
106
+ const durationMs = Date.now() - startTime;
107
+ console.error(`[MCP] ✅ Success: ${toolName} (${durationMs}ms)`);
108
+ const jsonStr = JSON.stringify(result, null, 2);
109
+ // Safety limit: ~100kb JSON is roughly 20-30k tokens.
110
+ // Usually happens if LLMs ask for 50+ years of transits or raw ephemeris arrays.
111
+ if (jsonStr.length > 100_000) {
112
+ console.error(`[MCP] ⚠️ Warning: Payload too large (${(jsonStr.length / 1024).toFixed(1)}kb) for ${toolName}`);
113
+ return {
114
+ content: [
115
+ {
116
+ type: "text",
117
+ text: JSON.stringify({
118
+ success: false,
119
+ error: "PAYLOAD_TOO_LARGE",
120
+ message: `The requested query produced too much data (${(jsonStr.length / 1024).toFixed(1)}kb). Please significantly narrow your request parameters (e.g., fewer years, smaller coordinate bounding box, etc.) to fit within context limits.`
121
+ }, null, 2),
122
+ },
123
+ ],
124
+ isError: true,
125
+ };
126
+ }
104
127
  return {
105
128
  content: [
106
129
  {
107
130
  type: "text",
108
- text: JSON.stringify(result, null, 2),
131
+ text: jsonStr,
109
132
  },
110
133
  ],
111
134
  };
112
135
  }
113
136
  catch (error) {
137
+ const durationMs = Date.now() - startTime;
114
138
  const errorMessage = error instanceof Error ? error.message : String(error);
139
+ console.error(`[MCP] ❌ Failed: ${toolName} (${durationMs}ms) - ${errorMessage}`);
115
140
  return {
116
141
  content: [
117
142
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openephemeris/mcp-server",
3
- "version": "3.2.6",
3
+ "version": "3.2.7",
4
4
  "description": "Model Context Protocol server for the Open Ephemeris astronomical computation API",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -42,7 +42,11 @@
42
42
  "astrology",
43
43
  "astronomy",
44
44
  "ephemeris",
45
- "openephemeris"
45
+ "openephemeris",
46
+ "llm",
47
+ "claude",
48
+ "ai",
49
+ "swiss ephemeris"
46
50
  ],
47
51
  "author": "Open Ephemeris",
48
52
  "license": "MIT",