@michaleffffff/mcp-trading-server 2.2.0 → 2.2.2
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/redirection.js +21 -0
- package/dist/server.js +14 -27
- package/package.json +1 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Global stdout redirection for MCP JSON-RPC compatibility.
|
|
3
|
+
* This file MUST be imported before any other module that might perform logging
|
|
4
|
+
* or import the @myx-trade/sdk.
|
|
5
|
+
*/
|
|
6
|
+
const originalStdoutWrite = process.stdout.write.bind(process.stdout);
|
|
7
|
+
process.stdout.write = (chunk, encoding, callback) => {
|
|
8
|
+
const output = chunk.toString();
|
|
9
|
+
// JSON-RPC messages always start with { "jsonrpc": "2.0"
|
|
10
|
+
if (output.trim().startsWith('{') && output.includes('"jsonrpc"')) {
|
|
11
|
+
return originalStdoutWrite(chunk, encoding, callback);
|
|
12
|
+
}
|
|
13
|
+
// Everything else goes to stderr
|
|
14
|
+
return process.stderr.write(chunk, encoding, callback);
|
|
15
|
+
};
|
|
16
|
+
// Also explicitly redirect console.log to console.error
|
|
17
|
+
console.log = console.error;
|
|
18
|
+
console.info = console.error;
|
|
19
|
+
console.debug = console.error;
|
|
20
|
+
console.warn = console.error;
|
|
21
|
+
export {};
|
package/dist/server.js
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return process.stderr.write(chunk, encoding, callback);
|
|
15
|
-
};
|
|
2
|
+
import "./redirection.js";
|
|
3
|
+
import "dotenv/config";
|
|
4
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
5
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
6
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, ListResourcesRequestSchema, ReadResourceRequestSchema, ListPromptsRequestSchema, GetPromptRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
// Tools & Modules
|
|
9
|
+
import * as baseTools from "./tools/index.js";
|
|
10
|
+
import * as baseResources from "./resources/index.js";
|
|
11
|
+
import * as basePrompts from "./prompts/index.js";
|
|
12
|
+
import { logger } from "./utils/logger.js";
|
|
13
|
+
import { MCPError, ErrorCode } from "./utils/errors.js";
|
|
16
14
|
// --- Process Logic Protection ---
|
|
17
15
|
// Catch unhandled promise rejections
|
|
18
16
|
process.on('unhandledRejection', (reason, promise) => {
|
|
@@ -31,17 +29,6 @@ const shutdown = () => {
|
|
|
31
29
|
};
|
|
32
30
|
process.on('SIGINT', shutdown);
|
|
33
31
|
process.on('SIGTERM', shutdown);
|
|
34
|
-
import "dotenv/config";
|
|
35
|
-
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
36
|
-
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
37
|
-
import { CallToolRequestSchema, ListToolsRequestSchema, ListResourcesRequestSchema, ReadResourceRequestSchema, ListPromptsRequestSchema, GetPromptRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
38
|
-
import { z } from "zod";
|
|
39
|
-
// Tools & Modules
|
|
40
|
-
import * as baseTools from "./tools/index.js";
|
|
41
|
-
import * as baseResources from "./resources/index.js";
|
|
42
|
-
import * as basePrompts from "./prompts/index.js";
|
|
43
|
-
import { logger } from "./utils/logger.js";
|
|
44
|
-
import { MCPError, ErrorCode } from "./utils/errors.js";
|
|
45
32
|
// ─── 注册表 ───
|
|
46
33
|
const allTools = Object.values(baseTools);
|
|
47
34
|
const allResources = Object.values(baseResources);
|
|
@@ -80,7 +67,7 @@ function zodSchemaToJsonSchema(zodSchema) {
|
|
|
80
67
|
};
|
|
81
68
|
}
|
|
82
69
|
// ─── MCP Server ───
|
|
83
|
-
const server = new Server({ name: "myx-mcp-trading-server", version: "2.2.
|
|
70
|
+
const server = new Server({ name: "myx-mcp-trading-server", version: "2.2.2" }, { capabilities: { tools: {}, resources: {}, prompts: {} } });
|
|
84
71
|
// List tools
|
|
85
72
|
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
86
73
|
return {
|
|
@@ -180,7 +167,7 @@ server.setRequestHandler(GetPromptRequestSchema, async (request) => {
|
|
|
180
167
|
async function main() {
|
|
181
168
|
const transport = new StdioServerTransport();
|
|
182
169
|
await server.connect(transport);
|
|
183
|
-
logger.info("🚀 MYX Trading MCP Server v2.
|
|
170
|
+
logger.info("🚀 MYX Trading MCP Server v2.2.2 running (stdio, pure on-chain, prod ready)");
|
|
184
171
|
}
|
|
185
172
|
main().catch((err) => {
|
|
186
173
|
logger.error("Fatal Server Startup Error", err);
|