fixparser-plugin-mcp 9.1.7-555b7cf3 → 9.1.7-57d70bb1
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/build/cjs/MCPLocal.js +2 -2
- package/build/cjs/MCPLocal.js.map +2 -2
- package/build/cjs/MCPRemote.js +88 -144
- package/build/cjs/MCPRemote.js.map +2 -2
- package/build/esm/MCPLocal.mjs +2 -2
- package/build/esm/MCPLocal.mjs.map +2 -2
- package/build/esm/MCPRemote.mjs +88 -144
- package/build/esm/MCPRemote.mjs.map +2 -2
- package/build-examples/cjs/example_mcp_local.js +7 -7
- package/build-examples/cjs/example_mcp_local.js.map +4 -4
- package/build-examples/esm/example_mcp_local.mjs +7 -7
- package/build-examples/esm/example_mcp_local.mjs.map +4 -4
- package/package.json +5 -5
- package/build/cjs/index.js +0 -1347
- package/build/cjs/index.js.map +0 -7
- package/build/esm/index.mjs +0 -1309
- package/build/esm/index.mjs.map +0 -7
- package/build-examples/cjs/example_mcp_remote.js +0 -16
- package/build-examples/cjs/example_mcp_remote.js.map +0 -7
- package/build-examples/esm/example_mcp_remote.mjs +0 -16
- package/build-examples/esm/example_mcp_remote.mjs.map +0 -7
package/build/esm/MCPRemote.mjs
CHANGED
|
@@ -132,7 +132,7 @@ var toolSchemas = {
|
|
|
132
132
|
}
|
|
133
133
|
},
|
|
134
134
|
executeOrder: {
|
|
135
|
-
description: "Executes a verified order. verifyOrder must be called before executeOrder.",
|
|
135
|
+
description: "Executes a verified order. verifyOrder must be called before executeOrder. user has to explicitly allow executeOrder.",
|
|
136
136
|
schema: {
|
|
137
137
|
type: "object",
|
|
138
138
|
properties: {
|
|
@@ -813,7 +813,7 @@ function handleMessage(message, parser, pendingRequests, marketDataPrices, maxPr
|
|
|
813
813
|
message: `MCP Server received message: ${message.messageType}: ${message.description}`
|
|
814
814
|
});
|
|
815
815
|
const msgType = message.messageType;
|
|
816
|
-
if (msgType === Messages3.MarketDataSnapshotFullRefresh
|
|
816
|
+
if (msgType === Messages3.MarketDataSnapshotFullRefresh) {
|
|
817
817
|
const symbol = message.getField(Fields3.Symbol)?.value;
|
|
818
818
|
const entries = message.getField(Fields3.NoMDEntries)?.value;
|
|
819
819
|
let bid = 0;
|
|
@@ -865,39 +865,6 @@ function handleMessage(message, parser, pendingRequests, marketDataPrices, maxPr
|
|
|
865
865
|
|
|
866
866
|
// src/MCPRemote.ts
|
|
867
867
|
var transports = {};
|
|
868
|
-
function jsonSchemaToZod(schema) {
|
|
869
|
-
if (schema.type === "object") {
|
|
870
|
-
const shape = {};
|
|
871
|
-
for (const [key, prop] of Object.entries(schema.properties || {})) {
|
|
872
|
-
const propSchema = prop;
|
|
873
|
-
if (propSchema.type === "string") {
|
|
874
|
-
if (propSchema.enum) {
|
|
875
|
-
shape[key] = z.enum(propSchema.enum);
|
|
876
|
-
} else {
|
|
877
|
-
shape[key] = z.string();
|
|
878
|
-
}
|
|
879
|
-
} else if (propSchema.type === "number") {
|
|
880
|
-
shape[key] = z.number();
|
|
881
|
-
} else if (propSchema.type === "boolean") {
|
|
882
|
-
shape[key] = z.boolean();
|
|
883
|
-
} else if (propSchema.type === "array") {
|
|
884
|
-
if (propSchema.items.type === "string") {
|
|
885
|
-
shape[key] = z.array(z.string());
|
|
886
|
-
} else if (propSchema.items.type === "number") {
|
|
887
|
-
shape[key] = z.array(z.number());
|
|
888
|
-
} else if (propSchema.items.type === "boolean") {
|
|
889
|
-
shape[key] = z.array(z.boolean());
|
|
890
|
-
} else {
|
|
891
|
-
shape[key] = z.array(z.any());
|
|
892
|
-
}
|
|
893
|
-
} else {
|
|
894
|
-
shape[key] = z.any();
|
|
895
|
-
}
|
|
896
|
-
}
|
|
897
|
-
return shape;
|
|
898
|
-
}
|
|
899
|
-
return {};
|
|
900
|
-
}
|
|
901
868
|
var MCPRemote = class extends MCPBase {
|
|
902
869
|
/**
|
|
903
870
|
* Port number the server will listen on.
|
|
@@ -962,30 +929,42 @@ var MCPRemote = class extends MCPBase {
|
|
|
962
929
|
this.parser,
|
|
963
930
|
this.pendingRequests,
|
|
964
931
|
this.marketDataPrices,
|
|
965
|
-
this.MAX_PRICE_HISTORY
|
|
932
|
+
this.MAX_PRICE_HISTORY,
|
|
933
|
+
(symbol, data) => {
|
|
934
|
+
this.mcpServer?.tool(
|
|
935
|
+
"priceUpdate",
|
|
936
|
+
{
|
|
937
|
+
description: "Price update notification",
|
|
938
|
+
schema: z.object({
|
|
939
|
+
symbol: z.string(),
|
|
940
|
+
timestamp: z.number(),
|
|
941
|
+
bid: z.number(),
|
|
942
|
+
offer: z.number(),
|
|
943
|
+
spread: z.number(),
|
|
944
|
+
volume: z.number()
|
|
945
|
+
})
|
|
946
|
+
},
|
|
947
|
+
() => ({
|
|
948
|
+
content: [
|
|
949
|
+
{
|
|
950
|
+
type: "text",
|
|
951
|
+
text: JSON.stringify({ symbol, ...data })
|
|
952
|
+
}
|
|
953
|
+
]
|
|
954
|
+
})
|
|
955
|
+
);
|
|
956
|
+
}
|
|
966
957
|
);
|
|
967
958
|
}
|
|
968
959
|
});
|
|
969
960
|
this.httpServer = createServer(async (req, res) => {
|
|
970
|
-
this.logger?.log({
|
|
971
|
-
level: "info",
|
|
972
|
-
message: `Incoming request: ${req.method} ${req.url}`
|
|
973
|
-
});
|
|
974
961
|
if (!req.url || !req.method) {
|
|
975
|
-
this.logger?.log({
|
|
976
|
-
level: "error",
|
|
977
|
-
message: "Invalid request: missing URL or method"
|
|
978
|
-
});
|
|
979
962
|
res.writeHead(400);
|
|
980
963
|
res.end("Bad Request");
|
|
981
964
|
return;
|
|
982
965
|
}
|
|
983
966
|
if (req.url === "/mcp") {
|
|
984
967
|
const sessionId = req.headers["mcp-session-id"];
|
|
985
|
-
this.logger?.log({
|
|
986
|
-
level: "info",
|
|
987
|
-
message: `MCP request received. Session ID: ${sessionId || "none"}, headers: ${req.headers}`
|
|
988
|
-
});
|
|
989
968
|
if (req.method === "POST") {
|
|
990
969
|
const bodyChunks = [];
|
|
991
970
|
req.on("data", (chunk) => {
|
|
@@ -996,47 +975,23 @@ var MCPRemote = class extends MCPBase {
|
|
|
996
975
|
const body = Buffer.concat(bodyChunks).toString();
|
|
997
976
|
try {
|
|
998
977
|
parsed = JSON.parse(body);
|
|
999
|
-
this.logger?.log({
|
|
1000
|
-
level: "info",
|
|
1001
|
-
message: `Parsed request body: ${JSON.stringify(parsed)}`
|
|
1002
|
-
});
|
|
1003
978
|
} catch (err) {
|
|
1004
|
-
this.logger?.log({
|
|
1005
|
-
level: "error",
|
|
1006
|
-
message: `Failed to parse JSON body: ${err}`
|
|
1007
|
-
});
|
|
1008
979
|
res.writeHead(400);
|
|
1009
980
|
res.end(JSON.stringify({ error: "Invalid JSON" }));
|
|
1010
981
|
return;
|
|
1011
982
|
}
|
|
1012
983
|
let transport;
|
|
1013
984
|
if (sessionId && transports[sessionId]) {
|
|
1014
|
-
this.logger?.log({
|
|
1015
|
-
level: "info",
|
|
1016
|
-
message: `Using existing transport for session: ${sessionId}`
|
|
1017
|
-
});
|
|
1018
985
|
transport = transports[sessionId];
|
|
1019
986
|
} else if (!sessionId && req.method === "POST" && isInitializeRequest(parsed)) {
|
|
1020
|
-
this.logger?.log({
|
|
1021
|
-
level: "info",
|
|
1022
|
-
message: "Creating new transport for initialization request"
|
|
1023
|
-
});
|
|
1024
987
|
transport = new StreamableHTTPServerTransport({
|
|
1025
988
|
sessionIdGenerator: () => randomUUID(),
|
|
1026
989
|
onsessioninitialized: (sessionId2) => {
|
|
1027
|
-
this.logger?.log({
|
|
1028
|
-
level: "info",
|
|
1029
|
-
message: `New session initialized: ${sessionId2}`
|
|
1030
|
-
});
|
|
1031
990
|
transports[sessionId2] = transport;
|
|
1032
991
|
}
|
|
1033
992
|
});
|
|
1034
993
|
transport.onclose = () => {
|
|
1035
994
|
if (transport.sessionId) {
|
|
1036
|
-
this.logger?.log({
|
|
1037
|
-
level: "info",
|
|
1038
|
-
message: `Session closed: ${transport.sessionId}`
|
|
1039
|
-
});
|
|
1040
995
|
delete transports[transport.sessionId];
|
|
1041
996
|
}
|
|
1042
997
|
};
|
|
@@ -1047,10 +1002,6 @@ var MCPRemote = class extends MCPBase {
|
|
|
1047
1002
|
this.setupTools();
|
|
1048
1003
|
await this.mcpServer.connect(transport);
|
|
1049
1004
|
} else {
|
|
1050
|
-
this.logger?.log({
|
|
1051
|
-
level: "error",
|
|
1052
|
-
message: "Invalid request: No valid session ID provided"
|
|
1053
|
-
});
|
|
1054
1005
|
res.writeHead(400, { "Content-Type": "application/json" });
|
|
1055
1006
|
res.end(
|
|
1056
1007
|
JSON.stringify({
|
|
@@ -1064,57 +1015,21 @@ var MCPRemote = class extends MCPBase {
|
|
|
1064
1015
|
);
|
|
1065
1016
|
return;
|
|
1066
1017
|
}
|
|
1067
|
-
|
|
1068
|
-
await transport.handleRequest(req, res, parsed);
|
|
1069
|
-
this.logger?.log({
|
|
1070
|
-
level: "info",
|
|
1071
|
-
message: "Request handled successfully"
|
|
1072
|
-
});
|
|
1073
|
-
} catch (error) {
|
|
1074
|
-
this.logger?.log({
|
|
1075
|
-
level: "error",
|
|
1076
|
-
message: `Error handling request: ${error}`
|
|
1077
|
-
});
|
|
1078
|
-
throw error;
|
|
1079
|
-
}
|
|
1018
|
+
await transport.handleRequest(req, res, parsed);
|
|
1080
1019
|
});
|
|
1081
1020
|
} else if (req.method === "GET" || req.method === "DELETE") {
|
|
1082
1021
|
if (!sessionId || !transports[sessionId]) {
|
|
1083
|
-
this.logger?.log({
|
|
1084
|
-
level: "error",
|
|
1085
|
-
message: `Invalid session ID for ${req.method} request: ${sessionId}`
|
|
1086
|
-
});
|
|
1087
1022
|
res.writeHead(400);
|
|
1088
1023
|
res.end("Invalid or missing session ID");
|
|
1089
1024
|
return;
|
|
1090
1025
|
}
|
|
1091
1026
|
const transport = transports[sessionId];
|
|
1092
|
-
|
|
1093
|
-
await transport.handleRequest(req, res);
|
|
1094
|
-
this.logger?.log({
|
|
1095
|
-
level: "info",
|
|
1096
|
-
message: `${req.method} request handled successfully for session: ${sessionId}`
|
|
1097
|
-
});
|
|
1098
|
-
} catch (error) {
|
|
1099
|
-
this.logger?.log({
|
|
1100
|
-
level: "error",
|
|
1101
|
-
message: `Error handling ${req.method} request: ${error}`
|
|
1102
|
-
});
|
|
1103
|
-
throw error;
|
|
1104
|
-
}
|
|
1027
|
+
await transport.handleRequest(req, res);
|
|
1105
1028
|
} else {
|
|
1106
|
-
this.logger?.log({
|
|
1107
|
-
level: "error",
|
|
1108
|
-
message: `Method not allowed: ${req.method}`
|
|
1109
|
-
});
|
|
1110
1029
|
res.writeHead(405);
|
|
1111
1030
|
res.end("Method Not Allowed");
|
|
1112
1031
|
}
|
|
1113
1032
|
} else {
|
|
1114
|
-
this.logger?.log({
|
|
1115
|
-
level: "error",
|
|
1116
|
-
message: `Not found: ${req.url}`
|
|
1117
|
-
});
|
|
1118
1033
|
res.writeHead(404);
|
|
1119
1034
|
res.end("Not Found");
|
|
1120
1035
|
}
|
|
@@ -1144,40 +1059,69 @@ var MCPRemote = class extends MCPBase {
|
|
|
1144
1059
|
});
|
|
1145
1060
|
return;
|
|
1146
1061
|
}
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1062
|
+
this.mcpServer.tool(
|
|
1063
|
+
"tools/list",
|
|
1064
|
+
{
|
|
1065
|
+
description: "List available tools",
|
|
1066
|
+
schema: z.object({})
|
|
1067
|
+
},
|
|
1068
|
+
async () => {
|
|
1069
|
+
return {
|
|
1070
|
+
content: [
|
|
1071
|
+
{
|
|
1072
|
+
type: "text",
|
|
1073
|
+
text: JSON.stringify(
|
|
1074
|
+
Object.entries(toolSchemas).map(([name, { description, schema }]) => ({
|
|
1075
|
+
name,
|
|
1076
|
+
description,
|
|
1077
|
+
inputSchema: schema
|
|
1078
|
+
}))
|
|
1079
|
+
)
|
|
1080
|
+
}
|
|
1081
|
+
]
|
|
1082
|
+
};
|
|
1083
|
+
}
|
|
1152
1084
|
);
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1085
|
+
this.mcpServer.tool(
|
|
1086
|
+
"tools/call",
|
|
1087
|
+
{
|
|
1088
|
+
description: "Call a tool",
|
|
1089
|
+
schema: z.object({
|
|
1090
|
+
name: z.string(),
|
|
1091
|
+
arguments: z.any(),
|
|
1092
|
+
_meta: z.object({
|
|
1093
|
+
progressToken: z.number()
|
|
1094
|
+
}).optional()
|
|
1095
|
+
})
|
|
1096
|
+
},
|
|
1097
|
+
async (request) => {
|
|
1098
|
+
const { name, arguments: args } = request;
|
|
1099
|
+
const toolHandlers = createToolHandlers(
|
|
1100
|
+
this.parser,
|
|
1101
|
+
this.verifiedOrders,
|
|
1102
|
+
this.pendingRequests,
|
|
1103
|
+
this.marketDataPrices
|
|
1104
|
+
);
|
|
1105
|
+
const handler = toolHandlers[name];
|
|
1106
|
+
if (!handler) {
|
|
1174
1107
|
return {
|
|
1175
|
-
content:
|
|
1176
|
-
|
|
1108
|
+
content: [
|
|
1109
|
+
{
|
|
1110
|
+
type: "text",
|
|
1111
|
+
text: `Tool not found: ${name}`,
|
|
1112
|
+
uri: name
|
|
1113
|
+
}
|
|
1114
|
+
],
|
|
1115
|
+
isError: true
|
|
1177
1116
|
};
|
|
1178
1117
|
}
|
|
1179
|
-
|
|
1180
|
-
|
|
1118
|
+
const result = await handler(args);
|
|
1119
|
+
return {
|
|
1120
|
+
content: result.content,
|
|
1121
|
+
isError: result.isError
|
|
1122
|
+
};
|
|
1123
|
+
}
|
|
1124
|
+
);
|
|
1181
1125
|
}
|
|
1182
1126
|
};
|
|
1183
1127
|
export {
|