fixparser-plugin-mcp 9.1.7-fa7eb92e → 9.1.7-fbc175db
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 +882 -598
- package/build/cjs/MCPLocal.js.map +4 -4
- package/build/esm/MCPLocal.mjs +872 -604
- package/build/esm/MCPLocal.mjs.map +4 -4
- package/build-examples/cjs/example_mcp_local.js +14 -4
- package/build-examples/cjs/example_mcp_local.js.map +4 -4
- package/build-examples/esm/example_mcp_local.mjs +14 -4
- package/build-examples/esm/example_mcp_local.mjs.map +4 -4
- package/package.json +6 -6
- package/types/MCPLocal.d.ts +3 -0
- package/types/schemas/index.d.ts +15 -0
- package/types/schemas/schemas.d.ts +168 -0
- package/types/tools/index.d.ts +17 -0
- package/types/tools/marketData.d.ts +40 -0
- package/types/tools/order.d.ts +12 -0
- package/types/tools/parse.d.ts +5 -0
- package/types/tools/parseToJSON.d.ts +5 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../examples/example_mcp_local.ts", "../../src/MCPLocal.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n EncryptMethod,\n FIXParser,\n Field,\n Fields,\n LicenseManager,\n type Message,\n Messages,\n type Options,\n ResetSeqNumFlag,\n} from 'fixparser';\nimport { MCPLocal } from 'fixparser-plugin-mcp';\n\nconst SENDER = 'CLIENT2';\nconst TARGET = 'EXECUTOR';\n\nconst initializeServer = async () => {\n await LicenseManager.setLicenseKey(process.env.FIXPARSER_LICENSE_KEY);\n\n const fixParser: FIXParser = new FIXParser({\n logging: false,\n // logOptions: {\n // name: SENDER,\n // level: 'info',\n // format: 'jsonrpc',\n // transport: new ConsoleLogTransport({ format: 'jsonrpc' }),\n // },\n plugins: [new MCPLocal({ port: 3099, onReady: () => {} })],\n });\n\n const sendLogon = () => {\n const logon = fixParser.createMessage(\n new Field(Fields.MsgType, Messages.Logon),\n new Field(Fields.MsgSeqNum, fixParser.getNextTargetMsgSeqNum()),\n new Field(Fields.SenderCompID, SENDER),\n new Field(Fields.SendingTime, fixParser.getTimestamp()),\n new Field(Fields.TargetCompID, TARGET),\n new Field(Fields.ResetSeqNumFlag, ResetSeqNumFlag.Yes),\n new Field(Fields.EncryptMethod, EncryptMethod.None),\n new Field(Fields.HeartBtInt, 10),\n );\n fixParser.send(logon);\n };\n\n const CONNECT_PARAMS: Options = {\n host: process.env.FIXPARSER_HOST || '10.0.1.42',\n port: process.env.FIXPARSER_PORT ? Number.parseInt(process.env.FIXPARSER_PORT, 10) : 5001,\n protocol: 'tcp',\n sender: process.env.FIXPARSER_SENDER || SENDER,\n target: process.env.FIXPARSER_TARGET || TARGET,\n fixVersion: process.env.FIXPARSER_TARGET || 'FIX.4.4',\n onOpen: () => {\n sendLogon();\n },\n onMessage: (message: Message) => {},\n onClose: () => {\n // console.log(\n // JSON.stringify(\n // {\n // event: 'FIX Connection closed',\n // action: 'Attempting to reconnect in 1 second',\n // },\n // null,\n // 2,\n // ),\n // );\n setTimeout(() => {\n // console.log(\n // JSON.stringify(\n // {\n // event: 'Reconnecting',\n // },\n // null,\n // 2,\n // ),\n // );\n fixParser.connect(CONNECT_PARAMS);\n }, 1000);\n },\n };\n\n fixParser.connect(CONNECT_PARAMS);\n};\n\ninitializeServer().catch((err) => console.error('Error initializing server:', err));\n", "import { Server } from '@modelcontextprotocol/sdk/server/index.js';\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport {\n CallToolRequestSchema,\n GetPromptRequestSchema,\n ListPromptsRequestSchema,\n ListResourcesRequestSchema,\n ListToolsRequestSchema,\n} from '@modelcontextprotocol/sdk/types.js';\n\nimport { Field, Fields, type IFIXParser, type Message, Messages } from 'fixparser';\nimport type { IPlugin } from 'fixparser-common';\nimport type { PluginOptions } from './PluginOptions';\n\n// Define JSON Schemas\nconst parseInputSchema = {\n type: 'object',\n properties: {\n fixString: {\n type: 'string',\n description: 'FIX message string to parse',\n },\n },\n required: ['fixString'],\n};\n\nconst parseToJSONInputSchema = {\n type: 'object',\n properties: {\n fixString: {\n type: 'string',\n description: 'FIX message string to parse',\n },\n },\n required: ['fixString'],\n};\n\nconst newOrderSingleInputSchema = {\n type: 'object',\n properties: {\n clOrdID: {\n type: 'string',\n description: 'Client Order ID',\n },\n handlInst: {\n type: 'string',\n enum: ['1', '2', '3'],\n description:\n 'Handling instruction (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use \"1\" for Manual, \"2\" for Automated, \"3\" for AutomatedNoIntervention)',\n },\n quantity: {\n type: 'number',\n description: 'Order quantity',\n },\n price: {\n type: 'number',\n description: 'Order price',\n },\n ordType: {\n type: 'string',\n enum: [\n '1',\n '2',\n '3',\n '4',\n '5',\n '6',\n '7',\n '8',\n '9',\n 'A',\n 'B',\n 'C',\n 'D',\n 'E',\n 'F',\n 'G',\n 'H',\n 'I',\n 'J',\n 'K',\n 'L',\n 'M',\n 'P',\n 'Q',\n 'R',\n 'S',\n ],\n description:\n 'Order type (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use \"1\" for Market, \"2\" for Limit, \"3\" for Stop)',\n },\n side: {\n type: 'string',\n enum: ['1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'],\n description:\n 'Order side (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use \"1\" for Buy, \"2\" for Sell, \"3\" for BuyMinus, \"4\" for SellPlus, \"5\" for SellShort, \"6\" for SellShortExempt, \"7\" for Undisclosed, \"8\" for Cross, \"9\" for CrossShort, \"A\" for CrossShortExempt, \"B\" for AsDefined, \"C\" for Opposite, \"D\" for Subscribe, \"E\" for Redeem, \"F\" for Lend, \"G\" for Borrow, \"H\" for SellUndisclosed)',\n },\n symbol: {\n type: 'string',\n description: 'Trading symbol',\n },\n timeInForce: {\n type: 'string',\n enum: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C'],\n description:\n 'Time in force (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use \"0\" for Day, \"1\" for Good Till Cancel, \"2\" for At Opening, \"3\" for Immediate or Cancel, \"4\" for Fill or Kill, \"5\" for Good Till Crossing, \"6\" for Good Till Date)',\n },\n },\n required: ['clOrdID', 'quantity', 'price', 'side', 'symbol'],\n};\n\nconst marketDataRequestInputSchema = {\n type: 'object',\n properties: {\n mdUpdateType: {\n type: 'string',\n enum: ['0', '1'],\n description:\n 'Market data update type (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use \"0\" for FullRefresh, \"1\" for IncrementalRefresh)',\n },\n symbol: {\n type: 'string',\n description: 'Trading symbol',\n },\n mdReqID: {\n type: 'string',\n description: 'Market data request ID',\n },\n subscriptionRequestType: {\n type: 'string',\n enum: ['0', '1', '2'],\n description:\n 'Subscription request type (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use \"0\" for Snapshot + Updates, \"1\" for Snapshot, \"2\" for Unsubscribe)',\n },\n mdEntryType: {\n type: 'string',\n enum: [\n '0',\n '1',\n '2',\n '3',\n '4',\n '5',\n '6',\n '7',\n '8',\n '9',\n 'A',\n 'B',\n 'C',\n 'D',\n 'E',\n 'F',\n 'G',\n 'H',\n 'J',\n 'K',\n 'L',\n 'M',\n 'N',\n 'O',\n 'P',\n 'Q',\n 'S',\n 'R',\n 'T',\n 'U',\n 'V',\n 'W',\n 'X',\n 'Y',\n 'Z',\n 'a',\n 'b',\n 'c',\n 'd',\n 'e',\n 'g',\n 'h',\n 'i',\n 't',\n ],\n description:\n 'Market data entry type (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use \"0\" for Bid, \"1\" for Offer, \"2\" for Trade, \"3\" for Index Value, \"4\" for Opening Price)',\n },\n },\n required: ['symbol', 'mdReqID'],\n};\n\nexport class MCPLocal implements IPlugin<IFIXParser> {\n // private logger: Logger | undefined;\n private parser: IFIXParser | undefined;\n private server: Server = new Server(\n {\n name: 'fixparser',\n version: '1.0.0',\n },\n {\n capabilities: {\n tools: {},\n prompts: {},\n resources: {},\n },\n },\n );\n private transport: StdioServerTransport = new StdioServerTransport();\n private onReady: (() => void) | undefined = undefined;\n\n private pendingRequests: Map<string, (data: Message) => void> = new Map();\n\n constructor({ logger, onReady }: PluginOptions) {\n if (onReady) this.onReady = onReady;\n }\n\n public async register(parser: IFIXParser): Promise<void> {\n this.parser = parser;\n this.parser.addOnMessageCallback((message: Message) => {\n // this.logger?.log({\n // level: 'info',\n // message: `FIXParser (MCP): (${parser.protocol?.toUpperCase()}): << received ${message.description}`,\n // });\n const msgType = message.messageType;\n if (\n msgType === Messages.MarketDataSnapshotFullRefresh ||\n msgType === Messages.ExecutionReport ||\n msgType === Messages.Reject\n ) {\n const idField =\n msgType === Messages.MarketDataSnapshotFullRefresh\n ? message.getField(Fields.MDReqID)\n : msgType === Messages.Reject\n ? message.getField(Fields.RefSeqNum)\n : message.getField(Fields.ClOrdID);\n if (idField) {\n const id = idField.value;\n if (typeof id === 'string' || typeof id === 'number') {\n // For Reject messages, check if it's related to a New Order Single\n if (msgType === Messages.Reject) {\n const refMsgType = message.getField(Fields.RefMsgType);\n if (refMsgType && refMsgType.value === Messages.NewOrderSingle) {\n const callback = this.pendingRequests.get(String(id));\n if (callback) {\n callback(message);\n this.pendingRequests.delete(String(id));\n }\n }\n } else {\n const callback = this.pendingRequests.get(String(id));\n if (callback) {\n callback(message);\n this.pendingRequests.delete(String(id));\n }\n }\n }\n }\n }\n });\n\n this.addWorkflows();\n\n await this.server.connect(this.transport);\n\n if (this.onReady) {\n this.onReady();\n }\n }\n\n private addWorkflows() {\n if (!this.parser) {\n // this.logger?.log({\n // level: 'error',\n // message: 'FIXParser (MCP): -- FIXParser instance not initialized. Ignoring setup of workflows...',\n // });\n return;\n }\n\n if (!this.server) {\n // this.logger?.log({\n // level: 'error',\n // message: 'FIXParser (MCP): -- MCP Server not initialized. Ignoring setup of workflows...',\n // });\n return;\n }\n\n // Helper function to validate and parse arguments\n const validateArgs = (args: any, schema: any): any => {\n // Basic validation - in a real implementation, you might want to use a proper JSON Schema validator\n const result: any = {};\n\n for (const [key, propSchema] of Object.entries(schema.properties || {})) {\n const prop = propSchema as any;\n const value = args?.[key];\n\n if (prop.required && (value === undefined || value === null)) {\n throw new Error(`Required property '${key}' is missing`);\n }\n\n if (value !== undefined) {\n // Apply defaults\n result[key] = value;\n } else if (prop.default !== undefined) {\n result[key] = prop.default;\n }\n }\n\n return result;\n };\n\n // Empty handler for resources\n this.server.setRequestHandler(ListResourcesRequestSchema, async () => {\n return {\n resources: [],\n };\n });\n\n // Handler for listing available tools\n this.server.setRequestHandler(ListToolsRequestSchema, async () => {\n return {\n tools: [\n {\n name: 'parse',\n description: 'Parses a FIX message and describes it in plain language',\n inputSchema: parseInputSchema,\n },\n {\n name: 'parseToJSON',\n description: 'Parses a FIX message into JSON',\n inputSchema: parseToJSONInputSchema,\n },\n {\n name: 'newOrderSingle',\n description: 'Creates and sends a New Order Single',\n inputSchema: newOrderSingleInputSchema,\n },\n {\n name: 'marketDataRequest',\n description: 'Sends a request for Market Data with the given symbol',\n inputSchema: marketDataRequestInputSchema,\n },\n ],\n };\n });\n\n // Handler for tool calls\n this.server.setRequestHandler(CallToolRequestSchema, async (request) => {\n const { name, arguments: args } = request.params;\n\n switch (name) {\n case 'parse': {\n try {\n const { fixString } = validateArgs(args, parseInputSchema);\n const parsedMessage: Message[] | undefined = this.parser?.parse(fixString);\n if (!parsedMessage || parsedMessage.length === 0) {\n return {\n isError: true,\n content: [{ type: 'text', text: 'Error: Failed to parse FIX string' }],\n };\n }\n\n return {\n content: [\n {\n type: 'text',\n text: `${parsedMessage[0].description}\n${parsedMessage[0].messageTypeDescription}`,\n },\n ],\n };\n } catch (error) {\n return {\n isError: true,\n content: [\n {\n type: 'text',\n text: `Error: ${error instanceof Error ? error.message : 'Failed to parse FIX string'}`,\n },\n ],\n };\n }\n }\n\n case 'parseToJSON': {\n try {\n const { fixString } = validateArgs(args, parseToJSONInputSchema);\n const parsedMessage = this.parser?.parse(fixString);\n if (!parsedMessage || parsedMessage.length === 0) {\n return {\n isError: true,\n content: [{ type: 'text', text: 'Error: Failed to parse FIX string' }],\n };\n }\n\n return {\n content: [\n {\n type: 'text',\n text: `${parsedMessage[0].toFIXJSON()}`,\n },\n ],\n };\n } catch (error) {\n return {\n isError: true,\n content: [\n {\n type: 'text',\n text: `Error: ${error instanceof Error ? error.message : 'Failed to parse FIX string'}`,\n },\n ],\n };\n }\n }\n\n case 'newOrderSingle': {\n try {\n const { clOrdID, handlInst, quantity, price, ordType, side, symbol, timeInForce } =\n validateArgs(args, newOrderSingleInputSchema);\n\n const response = new Promise((resolve) => {\n this.pendingRequests.set(clOrdID, resolve);\n });\n\n const order: Message | undefined = this.parser?.createMessage(\n new Field(Fields.MsgType, Messages.NewOrderSingle),\n new Field(Fields.MsgSeqNum, this.parser?.getNextTargetMsgSeqNum()),\n new Field(Fields.SenderCompID, this.parser?.sender),\n new Field(Fields.TargetCompID, this.parser?.target),\n new Field(Fields.SendingTime, this.parser?.getTimestamp()),\n new Field(Fields.ClOrdID, clOrdID),\n new Field(Fields.Side, side),\n new Field(Fields.Symbol, symbol),\n new Field(Fields.OrderQty, quantity),\n new Field(Fields.Price, price),\n new Field(Fields.OrdType, ordType),\n new Field(Fields.HandlInst, handlInst),\n new Field(Fields.TimeInForce, timeInForce),\n new Field(Fields.TransactTime, this.parser?.getTimestamp()),\n );\n\n if (!this.parser?.connected) {\n // this.logger?.log({\n // level: 'error',\n // message: 'FIXParser (MCP): -- Not connected. Ignoring message.',\n // });\n return {\n isError: true,\n content: [\n {\n type: 'text',\n text: 'Error: Not connected. Ignoring message.',\n },\n ],\n };\n }\n\n this.parser?.send(order!);\n // this.logger?.log({\n // level: 'info',\n // message: `FIXParser (MCP): (${this.parser?.protocol?.toUpperCase()}): >> sent ${order?.description}`,\n // });\n\n const fixData = await response;\n\n return {\n content: [\n {\n type: 'text',\n text:\n (fixData as Message).messageType === Messages.Reject\n ? `Reject message for order ${clOrdID}: ${JSON.stringify((fixData as Message).toFIXJSON())}`\n : `Execution Report for order ${clOrdID}: ${JSON.stringify((fixData as Message).toFIXJSON())}`,\n },\n ],\n };\n } catch (error) {\n return {\n isError: true,\n content: [\n {\n type: 'text',\n text: `Error: ${error instanceof Error ? error.message : 'Failed to create order'}`,\n },\n ],\n };\n }\n }\n\n case 'marketDataRequest': {\n try {\n const { mdUpdateType, symbol, mdReqID, subscriptionRequestType, mdEntryType } = validateArgs(\n args,\n marketDataRequestInputSchema,\n );\n\n const response = new Promise((resolve) => {\n this.pendingRequests.set(mdReqID, resolve);\n });\n\n const marketDataRequest = this.parser?.createMessage(\n new Field(Fields.MsgType, Messages.MarketDataRequest),\n new Field(Fields.SenderCompID, this.parser?.sender),\n new Field(Fields.MsgSeqNum, this.parser?.getNextTargetMsgSeqNum()),\n new Field(Fields.TargetCompID, this.parser?.target),\n new Field(Fields.SendingTime, this.parser?.getTimestamp()),\n new Field(Fields.MarketDepth, 0),\n new Field(Fields.MDUpdateType, mdUpdateType),\n new Field(Fields.NoRelatedSym, 1),\n new Field(Fields.Symbol, symbol),\n new Field(Fields.MDReqID, mdReqID),\n new Field(Fields.SubscriptionRequestType, subscriptionRequestType),\n new Field(Fields.NoMDEntryTypes, 1),\n new Field(Fields.MDEntryType, mdEntryType),\n );\n\n if (!this.parser?.connected) {\n // this.logger?.log({\n // level: 'error',\n // message: 'FIXParser (MCP): -- Not connected. Ignoring message.',\n // });\n return {\n isError: true,\n content: [\n {\n type: 'text',\n text: 'Error: Not connected. Ignoring message.',\n },\n ],\n };\n }\n\n this.parser?.send(marketDataRequest!);\n // this.logger?.log({\n // level: 'info',\n // message: `FIXParser (MCP): (${this.parser?.protocol?.toUpperCase()}): >> sent ${marketDataRequest?.description}`,\n // });\n\n const fixData = await response;\n\n return {\n content: [\n {\n type: 'text',\n text: `Market data for ${symbol}: ${JSON.stringify((fixData as Message).toFIXJSON())}`,\n },\n ],\n };\n } catch (error) {\n return {\n isError: true,\n content: [\n {\n type: 'text',\n text: `Error: ${error instanceof Error ? error.message : 'Failed to request market data'}`,\n },\n ],\n };\n }\n }\n\n default:\n throw new Error(`Unknown tool: ${name}`);\n }\n });\n\n this.server.setRequestHandler(ListPromptsRequestSchema, async () => {\n return {\n prompts: [\n {\n name: 'parse',\n description: 'Parses a FIX message and describes it in plain language',\n arguments: [\n {\n name: 'fixString',\n description: 'FIX message string to parse',\n required: true,\n },\n ],\n },\n {\n name: 'parseToJSON',\n description: 'Parses a FIX message into JSON',\n arguments: [\n {\n name: 'fixString',\n description: 'FIX message string to parse',\n required: true,\n },\n ],\n },\n {\n name: 'newOrderSingle',\n description: 'Creates and sends a New Order Single',\n arguments: [\n {\n name: 'clOrdID',\n description: 'Client Order ID',\n required: true,\n },\n {\n name: 'handlInst',\n description: 'Handling instruction',\n required: true,\n },\n {\n name: 'quantity',\n description: 'Order quantity',\n required: true,\n },\n {\n name: 'price',\n description: 'Order price',\n required: true,\n },\n {\n name: 'ordType',\n description: 'Order type',\n required: true,\n },\n {\n name: 'side',\n description:\n 'Order side (1=Buy, 2=Sell, 3=BuyMinus, 4=SellPlus, 5=SellShort, 6=SellShortExempt, 7=Undisclosed, 8=Cross, 9=CrossShort, A=CrossShortExempt, B=AsDefined, C=Opposite, D=Subscribe, E=Redeem, F=Lend, G=Borrow, H=SellUndisclosed)',\n required: true,\n },\n {\n name: 'symbol',\n description: 'Trading symbol',\n required: true,\n },\n {\n name: 'timeInForce',\n description: 'Time in force',\n required: true,\n },\n ],\n },\n {\n name: 'marketDataRequest',\n description: 'Sends a request for Market Data with the given symbol',\n arguments: [\n {\n name: 'mdUpdateType',\n description: 'Market data update type',\n required: true,\n },\n {\n name: 'symbol',\n description: 'Trading symbol',\n required: true,\n },\n {\n name: 'mdReqID',\n description: 'Market data request ID',\n required: true,\n },\n {\n name: 'subscriptionRequestType',\n description: 'Subscription request type',\n required: true,\n },\n {\n name: 'mdEntryType',\n description: 'Market data entry type',\n required: true,\n },\n ],\n },\n ],\n };\n });\n\n // Handler for getting specific prompts\n this.server.setRequestHandler(GetPromptRequestSchema, async (request) => {\n const { name, arguments: args } = request.params;\n\n switch (name) {\n case 'parse': {\n const fixString = args?.fixString || '';\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: `Please parse and explain this FIX message: ${fixString}`,\n },\n },\n ],\n };\n }\n\n case 'parseToJSON': {\n const fixString = args?.fixString || '';\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: `Please parse the FIX message to JSON: ${fixString}`,\n },\n },\n ],\n };\n }\n\n case 'newOrderSingle': {\n const { clOrdID, handlInst, quantity, price, ordType, side, symbol, timeInForce } = args || {};\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: [\n 'Create a New Order Single FIX message with the following parameters:',\n `- ClOrdID: ${clOrdID}`,\n `- HandlInst: ${handlInst ?? '3'} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '1' for Manual, '2' for Automated, '3' for AutomatedNoIntervention)`,\n `- Quantity: ${quantity}`,\n `- Price: ${price}`,\n `- OrdType: ${ordType ?? '1'} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '1' for Market, '2' for Limit, '3' for Stop)`,\n `- Side: ${side} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '1' for Buy, '2' for Sell)`,\n `- Symbol: ${symbol}`,\n `- TimeInForce: ${timeInForce ?? '0'} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '0' for Day, '1' for Good Till Cancel, '2' for At Opening, '3' for Immediate or Cancel, '4' for Fill or Kill, '5' for Good Till Crossing, '6' for Good Till Date)`,\n '',\n 'Note: For the OrdType parameter, always use the numeric/alphabetic value (e.g., \"1\" for Market, \"2\" for Limit, \"3\" for Stop) as defined in the FIX protocol, not the descriptive name.',\n 'Note: For the TimeInForce parameter, always use the numeric/alphabetic value (e.g., \"0\" for Day, \"1\" for Good Till Cancel, \"2\" for At Opening) as defined in the FIX protocol, not the descriptive name.',\n '',\n 'IMPORTANT: The response will be either:',\n '1. An Execution Report (MsgType=8) if the order was successfully placed',\n '2. A Reject message (MsgType=3) if the order failed to execute (e.g., due to missing or invalid parameters)',\n ].join('\\n'),\n },\n },\n ],\n };\n }\n\n case 'marketDataRequest': {\n const { mdUpdateType, symbol, mdReqID, subscriptionRequestType, mdEntryType } = args || {};\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: [\n 'Create a Market Data Request FIX message with the following parameters:',\n `- MDUpdateType: ${mdUpdateType ?? '0'} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '0' for FullRefresh, '1' for IncrementalRefresh)`,\n `- Symbol: ${symbol}`,\n `- MDReqID: ${mdReqID}`,\n `- SubscriptionRequestType: ${subscriptionRequestType ?? '0'} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '0' for Snapshot + Updates, '1' for Snapshot, '2' for Unsubscribe)`,\n `- MDEntryType: ${mdEntryType ?? '0'} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '0' for Bid, '1' for Offer, '2' for Trade, '3' for Index Value, '4' for Opening Price)`,\n '',\n 'Format the response as a JSON object with FIX tag numbers as keys and their corresponding values.',\n '',\n 'Note: For the MDUpdateType parameter, always use the numeric/alphabetic value (e.g., \"0\" for FullRefresh, \"1\" for IncrementalRefresh) as defined in the FIX protocol, not the descriptive name.',\n 'Note: For the SubscriptionRequestType parameter, always use the numeric/alphabetic value (e.g., \"0\" for Snapshot + Updates, \"1\" for Snapshot, \"2\" for Unsubscribe) as defined in the FIX protocol, not the descriptive name.',\n 'Note: For the MDEntryType parameter, always use the numeric/alphabetic value (e.g., \"0\" for Bid, \"1\" for Offer, \"2\" for Trade, \"3\" for Index Value, \"4\" for Opening Price) as defined in the FIX protocol, not the descriptive name.',\n ].join('\\n'),\n },\n },\n ],\n };\n }\n\n default:\n throw new Error(`Unknown prompt: ${name}`);\n }\n });\n\n process.on('SIGINT', async () => {\n await this.server.close();\n process.exit(0);\n });\n }\n}\n"],
|
|
5
|
-
"mappings": ";AAAA,OACI,iBAAAA,EACA,aAAAC,EACA,SAAAC,EACA,UAAAC,EACA,kBAAAC,EAEA,YAAAC,EAEA,mBAAAC,MACG,YCVP,OAAS,UAAAC,MAAc,4CACvB,OAAS,wBAAAC,MAA4B,4CACrC,OACI,yBAAAC,EACA,0BAAAC,EACA,4BAAAC,EACA,8BAAAC,EACA,0BAAAC,MACG,qCAEP,OAAS,SAAAC,EAAO,UAAAC,EAAuC,YAAAC,MAAgB,YAKvE,IAAMC,EAAmB,CACrB,KAAM,SACN,WAAY,CACR,UAAW,CACP,KAAM,SACN,YAAa,6BACjB,CACJ,EACA,SAAU,CAAC,WAAW,CAC1B,EAEMC,EAAyB,CAC3B,KAAM,SACN,WAAY,CACR,UAAW,CACP,KAAM,SACN,YAAa,6BACjB,CACJ,EACA,SAAU,CAAC,WAAW,CAC1B,EAEMC,EAA4B,CAC9B,KAAM,SACN,WAAY,CACR,QAAS,CACL,KAAM,SACN,YAAa,iBACjB,EACA,UAAW,CACP,KAAM,SACN,KAAM,CAAC,IAAK,IAAK,GAAG,EACpB,YACI,mLACR,EACA,SAAU,CACN,KAAM,SACN,YAAa,gBACjB,EACA,MAAO,CACH,KAAM,SACN,YAAa,aACjB,EACA,QAAS,CACL,KAAM,SACN,KAAM,CACF,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,GACJ,EACA,YACI,kJACR,EACA,KAAM,CACF,KAAM,SACN,KAAM,CAAC,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,GAAG,EAC1F,YACI,iaACR,EACA,OAAQ,CACJ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ACrD,IAAIH,EAAMC,EAAO,cAAeG,EAAc,IAAI,EAClD,IAAIJ,EAAMC,EAAO,WAAY,EAAE,CACnC,EACAN,EAAU,KAAKI,CAAK,CACxB,EAEMM,EAA0B,CAC5B,KAAM,QAAQ,IAAI,gBAAkB,YACpC,KAAM,QAAQ,IAAI,eAAiB,OAAO,SAAS,QAAQ,IAAI,eAAgB,EAAE,EAAI,KACrF,SAAU,MACV,OAAQ,QAAQ,IAAI,kBAAoBd,EACxC,OAAQ,QAAQ,IAAI,kBAAoBC,EACxC,WAAY,QAAQ,IAAI,kBAAoB,UAC5C,OAAQ,IAAM,CACVM,EAAU,CACd,EACA,UAAYQ,GAAqB,CAAC,EAClC,QAAS,IAAM,CAWX,WAAW,IAAM,CAUbX,EAAU,QAAQU,CAAc,CACpC,EAAG,GAAI,CACX,CACJ,EAEAV,EAAU,QAAQU,CAAc,CACpC,EAEAZ,EAAiB,EAAE,MAAOc,GAAQ,QAAQ,MAAM,6BAA8BA,CAAG,CAAC",
|
|
6
|
-
"names": ["EncryptMethod", "FIXParser", "Field", "Fields", "LicenseManager", "Messages", "ResetSeqNumFlag", "
|
|
3
|
+
"sources": ["../../examples/example_mcp_local.ts", "../../node_modules/fixparser-plugin-log-console/src/ConsoleLogTransport.ts", "../../src/MCPLocal.ts", "../../src/schemas/schemas.ts", "../../src/tools/marketData.ts", "../../src/tools/order.ts", "../../src/tools/parse.ts", "../../src/tools/parseToJSON.ts", "../../src/tools/index.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n EncryptMethod,\n FIXParser,\n Field,\n Fields,\n LicenseManager,\n Messages,\n type Options,\n ResetSeqNumFlag,\n} from 'fixparser';\nimport { ConsoleLogTransport } from 'fixparser-plugin-log-console';\nimport { MCPLocal } from 'fixparser-plugin-mcp';\n\nconst initializeServer = async () => {\n await LicenseManager.setLicenseKey(process.env.FIXPARSER_LICENSE_KEY);\n const SENDER = process.env.FIXPARSER_SENDER || 'SENDER';\n const TARGET = process.env.FIXPARSER_TARGET || 'TARGET';\n\n const fixParser: FIXParser = new FIXParser({\n logging: true,\n logOptions: {\n level: 'info',\n format: 'jsonrpc',\n transport: new ConsoleLogTransport({ format: 'jsonrpc' }),\n },\n plugins: [new MCPLocal({ port: 3099, onReady: () => {} })],\n });\n\n const sendLogon = () => {\n const logon = fixParser.createMessage(\n new Field(Fields.MsgType, Messages.Logon),\n new Field(Fields.MsgSeqNum, fixParser.getNextTargetMsgSeqNum()),\n new Field(Fields.SenderCompID, SENDER),\n new Field(Fields.SendingTime, fixParser.getTimestamp()),\n new Field(Fields.TargetCompID, TARGET),\n new Field(Fields.ResetSeqNumFlag, ResetSeqNumFlag.Yes),\n new Field(Fields.EncryptMethod, EncryptMethod.None),\n new Field(Fields.HeartBtInt, 10),\n );\n fixParser.send(logon);\n };\n\n const CONNECT_PARAMS: Options = {\n host: process.env.FIXPARSER_HOST || '10.0.1.42',\n port: process.env.FIXPARSER_PORT ? Number.parseInt(process.env.FIXPARSER_PORT, 10) : 5001,\n protocol: 'tcp',\n sender: SENDER,\n target: TARGET,\n fixVersion: 'FIX.4.4',\n onOpen: () => {\n fixParser.logger.log({\n level: 'info',\n message: 'FIXParser logging in...',\n });\n sendLogon();\n },\n onClose: () => {\n fixParser.logger.log({\n level: 'info',\n message: 'FIXParser disconnected. Reconnecting in 1 second...',\n });\n setTimeout(() => {\n fixParser.connect(CONNECT_PARAMS);\n }, 1000);\n },\n };\n\n fixParser.connect(CONNECT_PARAMS);\n};\n\ninitializeServer().catch((err) => console.error('Error initializing server:', err));\n", "import type { ILogTransporter, LogMessage } from 'fixparser-common';\n\n/**\n * Logger output format options.\n *\n * - 'console': Output log in plain text format\n * - 'json': Output log in JSON format\n * - 'jsonrpc': Output log in JSON-RPC 2.0 format\n *\n * @public\n */\nexport type ConsoleFormat = 'console' | 'json' | 'jsonrpc';\n\n/**\n * A LogTransporter implementation for logging to the console.\n * It supports text (console), JSON, and JSON-RPC 2.0 formats.\n */\nexport class ConsoleLogTransport implements ILogTransporter {\n private format: ConsoleFormat;\n private useStderr: boolean;\n\n constructor({ format = 'json', useStderr = false }: { format: ConsoleFormat; useStderr?: boolean }) {\n this.format = format;\n this.useStderr = useStderr;\n }\n\n /**\n * Configures the format for console logging (either 'console' for text, 'json', or 'jsonrpc').\n */\n configure(config: { format: 'console' | 'json' | 'jsonrpc'; useStderr?: boolean }): void {\n this.format = config.format || 'json';\n if (config.useStderr !== undefined) {\n this.useStderr = config.useStderr;\n }\n }\n\n /**\n * Sends the log message to the console in the configured format.\n */\n async send(log: LogMessage): Promise<void> {\n const logMethod = this.useStderr ? console.error : console.log;\n\n if (this.format === 'json') {\n logMethod(JSON.stringify(log));\n } else if (this.format === 'jsonrpc') {\n const { message, ...rest } = log;\n const jsonrpcMessage = {\n jsonrpc: '2.0',\n method: log.level,\n params: {\n message,\n ...rest,\n },\n id: log.id || Date.now(),\n };\n logMethod(JSON.stringify(jsonrpcMessage));\n } else {\n const { name, id, message, level, ...additionalProperties } = log;\n const kv = Object.entries(additionalProperties).map(([key, value]) => `${key}: ${value}`);\n let logMessage = '';\n if (name) {\n logMessage += `${name} `;\n }\n logMessage += `${id}: ${message}`;\n void kv;\n logMethod(logMessage, kv.join(', '));\n }\n }\n\n /**\n * Flushes the log buffer (if any buffering mechanism exists).\n */\n async flush(): Promise<void> {\n // No flushing needed for console transport\n }\n\n /**\n * Closes the transport (not needed for console, but keeping the method for consistency).\n */\n async close(): Promise<void> {\n // No close logic needed for console transport\n }\n\n /**\n * Returns the status of the transport (always \"connected\" for console).\n */\n status(): string {\n return 'connected';\n }\n}\n", "import { Server } from '@modelcontextprotocol/sdk/server/index.js';\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport type { Request } from '@modelcontextprotocol/sdk/types.js';\nimport { Fields, type IFIXParser, MDEntryType, type Message, Messages } from 'fixparser';\nimport type { IPlugin } from 'fixparser-common';\nimport { z } from 'zod';\nimport type { PluginOptions } from './PluginOptions';\nimport type { VerifiedOrder } from './schemas';\nimport { toolSchemas } from './schemas/schemas';\nimport { createToolHandlers } from './tools';\n\nexport class MCPLocal implements IPlugin<IFIXParser> {\n private parser: IFIXParser | undefined;\n private server: Server = new Server(\n {\n name: 'fixparser',\n version: '1.0.0',\n },\n {\n capabilities: {\n tools: Object.entries(toolSchemas).reduce(\n (acc, [name, { description, schema }]) => {\n acc[name] = {\n description,\n parameters: schema,\n };\n return acc;\n },\n {} as Record<string, { description: string; parameters: any }>,\n ),\n },\n },\n );\n private transport: StdioServerTransport = new StdioServerTransport();\n private onReady: (() => void) | undefined = undefined;\n\n private pendingRequests: Map<string, (data: Message) => void> = new Map();\n private verifiedOrders: Map<string, VerifiedOrder> = new Map();\n private marketDataPrices: Map<\n string,\n Array<{\n timestamp: number;\n bid: number;\n offer: number;\n spread: number;\n volume: number;\n }>\n > = new Map();\n private readonly MAX_PRICE_HISTORY = 100000; // Maximum number of price points to store per symbol\n\n constructor({ logger, onReady }: PluginOptions) {\n if (onReady) this.onReady = onReady;\n }\n\n public async register(parser: IFIXParser): Promise<void> {\n this.parser = parser;\n this.parser.addOnMessageCallback((message: Message) => {\n this.parser?.logger.log({\n level: 'info',\n message: `MCP Server received message: ${message.messageType}: ${message.description}`,\n });\n const msgType = message.messageType;\n if (\n msgType === Messages.MarketDataSnapshotFullRefresh ||\n msgType === Messages.ExecutionReport ||\n msgType === Messages.Reject ||\n msgType === Messages.MarketDataIncrementalRefresh\n ) {\n this.parser?.logger.log({\n level: 'info',\n message: `MCP Server handling message type: ${msgType}`,\n });\n\n let id: string | undefined;\n\n // Handle market data messages\n if (\n msgType === Messages.MarketDataIncrementalRefresh ||\n msgType === Messages.MarketDataSnapshotFullRefresh\n ) {\n const symbol = message.getField(Fields.Symbol);\n const entryType = message.getField(Fields.MDEntryType);\n const price = message.getField(Fields.MDEntryPx);\n const size = message.getField(Fields.MDEntrySize);\n const timestamp = message.getField(Fields.MDEntryTime)?.value || Date.now();\n\n if (symbol?.value && price?.value) {\n const symbolStr = String(symbol.value);\n const priceNum = Number(price.value);\n const sizeNum = size?.value ? Number(size.value) : 0;\n\n // Get or create price history array for this symbol\n const priceHistory = this.marketDataPrices.get(symbolStr) || [];\n const lastEntry = priceHistory[priceHistory.length - 1] || {\n timestamp: 0,\n bid: 0,\n offer: 0,\n spread: 0,\n volume: 0,\n };\n\n // Create new entry based on entry type\n const newEntry = {\n timestamp: Number(timestamp),\n bid: entryType?.value === MDEntryType.Bid ? priceNum : lastEntry.bid,\n offer: entryType?.value === MDEntryType.Offer ? priceNum : lastEntry.offer,\n spread:\n entryType?.value === MDEntryType.Offer\n ? priceNum - lastEntry.bid\n : entryType?.value === MDEntryType.Bid\n ? lastEntry.offer - priceNum\n : lastEntry.spread,\n volume: entryType?.value === MDEntryType.TradeVolume ? sizeNum : lastEntry.volume,\n };\n\n // Add new price point\n priceHistory.push(newEntry);\n\n // Trim history if it exceeds maximum size\n if (priceHistory.length > this.MAX_PRICE_HISTORY) {\n priceHistory.shift(); // Remove oldest price\n }\n\n // Update the map\n this.marketDataPrices.set(symbolStr, priceHistory);\n\n this.parser?.logger.log({\n level: 'info',\n message: `MCP Server added ${symbol}: ${JSON.stringify(newEntry)}`,\n });\n\n // Send notification about the new price\n this.server.notification({\n method: 'priceUpdate',\n params: {\n symbol: symbolStr,\n ...newEntry,\n },\n });\n }\n }\n\n // Extract the appropriate ID based on message type\n if (msgType === Messages.MarketDataSnapshotFullRefresh) {\n const mdReqID = message.getField(Fields.MDReqID);\n if (mdReqID) id = String(mdReqID.value);\n } else if (msgType === Messages.ExecutionReport) {\n const clOrdID = message.getField(Fields.ClOrdID);\n if (clOrdID) id = String(clOrdID.value);\n } else if (msgType === Messages.Reject) {\n const refSeqNum = message.getField(Fields.RefSeqNum);\n if (refSeqNum) id = String(refSeqNum.value);\n }\n\n // If we have an ID and it matches a pending request, resolve it\n if (id) {\n const callback = this.pendingRequests.get(id);\n if (callback) {\n callback(message);\n this.pendingRequests.delete(id);\n }\n }\n }\n });\n\n this.addWorkflows();\n\n await this.server.connect(this.transport);\n\n if (this.onReady) {\n this.onReady();\n }\n }\n\n private addWorkflows() {\n if (!this.parser) {\n return;\n }\n\n if (!this.server) {\n return;\n }\n\n // Add handler for tools/list\n this.server.setRequestHandler(\n z.object({ method: z.literal('tools/list') }),\n async (request: Request, extra) => {\n return {\n tools: Object.entries(toolSchemas).map(([name, { description, schema }]) => ({\n name,\n description,\n inputSchema: schema,\n })),\n };\n },\n );\n\n // Add handler for tools/call\n this.server.setRequestHandler(\n z.object({\n method: z.literal('tools/call'),\n params: z.object({\n name: z.string(),\n arguments: z.any(),\n _meta: z\n .object({\n progressToken: z.number(),\n })\n .optional(),\n }),\n }),\n async (request: Request, extra) => {\n const { name, arguments: args } = request.params as { name: string; arguments: any };\n\n const toolHandlers = createToolHandlers(\n this.parser!,\n this.verifiedOrders,\n this.pendingRequests,\n this.marketDataPrices,\n );\n\n const handler = toolHandlers[name];\n if (!handler) {\n return {\n content: [\n {\n type: 'text',\n text: `Tool not found: ${name}`,\n uri: name,\n },\n ],\n isError: true,\n };\n }\n\n const result = await handler(args);\n return {\n content: result.content,\n isError: result.isError,\n };\n },\n );\n\n process.on('SIGINT', async () => {\n await this.server.close();\n process.exit(0);\n });\n }\n}\n", "export const toolSchemas = {\n parse: {\n description: 'Parses a FIX message and describes it in plain language',\n schema: {\n type: 'object',\n properties: {\n fixString: { type: 'string' },\n },\n required: ['fixString'],\n },\n },\n parseToJSON: {\n description: 'Parses a FIX message into JSON',\n schema: {\n type: 'object',\n properties: {\n fixString: { type: 'string' },\n },\n required: ['fixString'],\n },\n },\n verifyOrder: {\n description: 'Verifies order parameters before execution. verifyOrder must be called before executeOrder.',\n schema: {\n type: 'object',\n properties: {\n clOrdID: { type: 'string' },\n handlInst: {\n type: 'string',\n enum: ['1', '2', '3'],\n description:\n 'Handling Instructions: 1=Automated Execution No Intervention, 2=Automated Execution Intervention OK, 3=Manual Order',\n },\n quantity: { type: 'string' },\n price: { type: 'string' },\n ordType: {\n type: 'string',\n enum: [\n '1',\n '2',\n '3',\n '4',\n '5',\n '6',\n '7',\n '8',\n '9',\n 'A',\n 'B',\n 'C',\n 'D',\n 'E',\n 'F',\n 'G',\n 'H',\n 'I',\n 'J',\n 'K',\n 'L',\n 'M',\n 'P',\n 'Q',\n 'R',\n 'S',\n ],\n description:\n 'Order Type: 1=Market, 2=Limit, 3=Stop, 4=StopLimit, 5=MarketOnClose, 6=WithOrWithout, 7=LimitOrBetter, 8=LimitWithOrWithout, 9=OnBasis, A=OnClose, B=LimitOnClose, C=ForexMarket, D=PreviouslyQuoted, E=PreviouslyIndicated, F=ForexLimit, G=ForexSwap, H=ForexPreviouslyQuoted, I=Funari, J=MarketIfTouched, K=MarketWithLeftOverAsLimit, L=PreviousFundValuationPoint, M=NextFundValuationPoint, P=Pegged, Q=CounterOrderSelection, R=StopOnBidOrOffer, S=StopLimitOnBidOrOffer',\n },\n side: {\n type: 'string',\n enum: ['1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'],\n description:\n 'Side: 1=Buy, 2=Sell, 3=BuyMinus, 4=SellPlus, 5=SellShort, 6=SellShortExempt, 7=Undisclosed, 8=Cross, 9=CrossShort, A=CrossShortExempt, B=AsDefined, C=Opposite, D=Subscribe, E=Redeem, F=Lend, G=Borrow, H=SellUndisclosed',\n },\n symbol: { type: 'string' },\n timeInForce: {\n type: 'string',\n enum: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C'],\n description:\n 'Time In Force: 0=Day, 1=GoodTillCancel, 2=AtTheOpening, 3=ImmediateOrCancel, 4=FillOrKill, 5=GoodTillCrossing, 6=GoodTillDate, 7=AtTheClose, 8=GoodThroughCrossing, 9=AtCrossing, A=GoodForTime, B=GoodForAuction, C=GoodForMonth',\n },\n },\n required: ['clOrdID', 'handlInst', 'quantity', 'price', 'ordType', 'side', 'symbol', 'timeInForce'],\n },\n },\n executeOrder: {\n description:\n 'Executes a verified order. verifyOrder must be called before executeOrder. user has to explicitly allow executeOrder.',\n schema: {\n type: 'object',\n properties: {\n clOrdID: { type: 'string' },\n handlInst: {\n type: 'string',\n enum: ['1', '2', '3'],\n description:\n 'Handling Instructions: 1=Automated Execution No Intervention, 2=Automated Execution Intervention OK, 3=Manual Order',\n },\n quantity: { type: 'string' },\n price: { type: 'string' },\n ordType: {\n type: 'string',\n enum: [\n '1',\n '2',\n '3',\n '4',\n '5',\n '6',\n '7',\n '8',\n '9',\n 'A',\n 'B',\n 'C',\n 'D',\n 'E',\n 'F',\n 'G',\n 'H',\n 'I',\n 'J',\n 'K',\n 'L',\n 'M',\n 'P',\n 'Q',\n 'R',\n 'S',\n ],\n description:\n 'Order Type: 1=Market, 2=Limit, 3=Stop, 4=StopLimit, 5=MarketOnClose, 6=WithOrWithout, 7=LimitOrBetter, 8=LimitWithOrWithout, 9=OnBasis, A=OnClose, B=LimitOnClose, C=ForexMarket, D=PreviouslyQuoted, E=PreviouslyIndicated, F=ForexLimit, G=ForexSwap, H=ForexPreviouslyQuoted, I=Funari, J=MarketIfTouched, K=MarketWithLeftOverAsLimit, L=PreviousFundValuationPoint, M=NextFundValuationPoint, P=Pegged, Q=CounterOrderSelection, R=StopOnBidOrOffer, S=StopLimitOnBidOrOffer',\n },\n side: {\n type: 'string',\n enum: ['1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'],\n description:\n 'Side: 1=Buy, 2=Sell, 3=BuyMinus, 4=SellPlus, 5=SellShort, 6=SellShortExempt, 7=Undisclosed, 8=Cross, 9=CrossShort, A=CrossShortExempt, B=AsDefined, C=Opposite, D=Subscribe, E=Redeem, F=Lend, G=Borrow, H=SellUndisclosed',\n },\n symbol: { type: 'string' },\n timeInForce: {\n type: 'string',\n enum: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C'],\n description:\n 'Time In Force: 0=Day, 1=GoodTillCancel, 2=AtTheOpening, 3=ImmediateOrCancel, 4=FillOrKill, 5=GoodTillCrossing, 6=GoodTillDate, 7=AtTheClose, 8=GoodThroughCrossing, 9=AtCrossing, A=GoodForTime, B=GoodForAuction, C=GoodForMonth',\n },\n },\n required: ['clOrdID', 'handlInst', 'quantity', 'price', 'ordType', 'side', 'symbol', 'timeInForce'],\n },\n },\n marketDataRequest: {\n description: 'Requests market data for specified symbols',\n schema: {\n type: 'object',\n properties: {\n mdUpdateType: {\n type: 'string',\n enum: ['0', '1'],\n description: 'Market Data Update Type: 0=Full Refresh, 1=Incremental Refresh',\n },\n symbols: { type: 'array', items: { type: 'string' } },\n mdReqID: { type: 'string' },\n subscriptionRequestType: {\n type: 'string',\n enum: ['0', '1', '2'],\n description:\n 'Subscription Request Type: 0=Snapshot, 1=Snapshot + Updates, 2=Disable Previous Snapshot + Update Request',\n },\n mdEntryTypes: {\n type: 'array',\n items: {\n type: 'string',\n enum: [\n '0',\n '1',\n '2',\n '3',\n '4',\n '5',\n '6',\n '7',\n '8',\n '9',\n 'A',\n 'B',\n 'C',\n 'D',\n 'E',\n 'F',\n 'G',\n 'H',\n 'I',\n 'J',\n 'K',\n 'L',\n 'M',\n 'N',\n 'O',\n 'P',\n 'Q',\n 'R',\n 'S',\n 'T',\n 'U',\n 'V',\n 'W',\n 'X',\n 'Y',\n 'Z',\n ],\n },\n description:\n 'Market Data Entry Types: 0=Bid, 1=Offer, 2=Trade, 3=Index Value, 4=Opening Price, 5=Closing Price, 6=Settlement Price, 7=High Price, 8=Low Price, 9=Trade Volume, A=Open Interest, B=Simulated Sell Price, C=Simulated Buy Price, D=Empty Book, E=Session High Bid, F=Session Low Offer, G=Fixing Price, H=Electronic Volume, I=Threshold Limits and Price Band Variation, J=Clearing Price, K=Open Interest Change, L=Last Trade Price, M=Last Trade Volume, N=Last Trade Time, O=Last Trade Tick, P=Last Trade Exchange, Q=Last Trade ID, R=Last Trade Side, S=Last Trade Price Change, T=Last Trade Price Change Percent, U=Last Trade Price Change Basis Points, V=Last Trade Price Change Points, W=Last Trade Price Change Ticks, X=Last Trade Price Change Ticks Percent, Y=Last Trade Price Change Ticks Basis Points, Z=Last Trade Price Change Ticks Points',\n },\n },\n required: ['mdUpdateType', 'symbols', 'mdReqID', 'subscriptionRequestType'],\n },\n },\n getStockGraph: {\n description: 'Generates a price chart for a given symbol',\n schema: {\n type: 'object',\n properties: {\n symbol: { type: 'string' },\n },\n required: ['symbol'],\n },\n },\n getStockPriceHistory: {\n description: 'Returns price history for a given symbol',\n schema: {\n type: 'object',\n properties: {\n symbol: { type: 'string' },\n },\n required: ['symbol'],\n },\n },\n};\n", "import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';\nimport { Field, Fields, type IFIXParser, MDEntryType, type Message, Messages } from 'fixparser';\nimport QuickChart from 'quickchart-js';\n\nexport const createMarketDataRequestHandler = (\n parser: IFIXParser,\n pendingRequests: Map<string, (data: Message) => void>,\n): ((args: {\n mdUpdateType: string;\n symbols: string[];\n mdReqID: string;\n subscriptionRequestType: string;\n mdEntryTypes?: string[];\n}) => Promise<CallToolResult>) => {\n return async (args: {\n mdUpdateType: string;\n symbols: string[];\n mdReqID: string;\n subscriptionRequestType: string;\n mdEntryTypes?: string[];\n }): Promise<CallToolResult> => {\n try {\n const response = new Promise((resolve) => {\n pendingRequests.set(args.mdReqID, resolve);\n });\n\n // Set default entry types if not provided\n const entryTypes = args.mdEntryTypes || [MDEntryType.Bid, MDEntryType.Offer, MDEntryType.TradeVolume];\n\n const messageFields = [\n new Field(Fields.MsgType, Messages.MarketDataRequest),\n new Field(Fields.SenderCompID, parser.sender),\n new Field(Fields.MsgSeqNum, parser.getNextTargetMsgSeqNum()),\n new Field(Fields.TargetCompID, parser.target),\n new Field(Fields.SendingTime, parser.getTimestamp()),\n new Field(Fields.MDReqID, args.mdReqID),\n new Field(Fields.SubscriptionRequestType, args.subscriptionRequestType),\n new Field(Fields.MarketDepth, 0),\n new Field(Fields.MDUpdateType, args.mdUpdateType),\n ];\n\n // Add each symbol to the message\n messageFields.push(new Field(Fields.NoRelatedSym, args.symbols.length));\n args.symbols.forEach((symbol: string) => {\n messageFields.push(new Field(Fields.Symbol, symbol));\n });\n\n // Add NoMDEntryTypes and each MDEntryType to the message\n messageFields.push(new Field(Fields.NoMDEntryTypes, entryTypes.length));\n entryTypes.forEach((entryType: string) => {\n messageFields.push(new Field(Fields.MDEntryType, entryType));\n });\n\n const mdr = parser.createMessage(...messageFields);\n\n if (!parser.connected) {\n return {\n content: [\n {\n type: 'text',\n text: 'Error: Not connected. Ignoring message.',\n uri: 'marketDataRequest',\n },\n ],\n isError: true,\n };\n }\n\n parser.send(mdr!);\n\n const fixData = await response;\n\n return {\n content: [\n {\n type: 'text',\n text: `Market data for ${args.symbols.join(', ')}: ${JSON.stringify((fixData as Message).toFIXJSON())}`,\n uri: 'marketDataRequest',\n },\n ],\n };\n } catch (error) {\n return {\n content: [\n {\n type: 'text',\n text: `Error: ${error instanceof Error ? error.message : 'Failed to request market data'}`,\n uri: 'marketDataRequest',\n },\n ],\n isError: true,\n };\n }\n };\n};\n\nexport const createGetStockGraphHandler = (\n marketDataPrices: Map<\n string,\n Array<{\n timestamp: number;\n bid: number;\n offer: number;\n spread: number;\n volume: number;\n }>\n >,\n): ((args: { symbol: string }) => Promise<CallToolResult>) => {\n return async (args: { symbol: string }): Promise<CallToolResult> => {\n try {\n const symbol = args.symbol;\n const priceHistory = marketDataPrices.get(symbol) || [];\n\n if (priceHistory.length === 0) {\n return {\n content: [\n {\n type: 'text',\n text: `No price data available for ${symbol}`,\n uri: 'getStockGraph',\n },\n ],\n };\n }\n\n const chart = new QuickChart();\n chart.setWidth(300);\n chart.setHeight(150);\n chart.setBackgroundColor('transparent');\n\n // Prepare the data\n const labels = priceHistory.map((point) => new Date(point.timestamp).toLocaleTimeString());\n const bidData = priceHistory.map((point) => point.bid);\n const offerData = priceHistory.map((point) => point.offer);\n const spreadData = priceHistory.map((point) => point.spread);\n const volumeData = priceHistory.map((point) => point.volume);\n\n const config = {\n type: 'line',\n data: {\n labels: labels,\n datasets: [\n {\n label: 'Bid',\n data: bidData,\n borderColor: '#28a745',\n backgroundColor: 'rgba(40, 167, 69, 0.1)',\n fill: false,\n tension: 0.4,\n },\n {\n label: 'Offer',\n data: offerData,\n borderColor: '#dc3545',\n backgroundColor: 'rgba(220, 53, 69, 0.1)',\n fill: false,\n tension: 0.4,\n },\n {\n label: 'Spread',\n data: spreadData,\n borderColor: '#6c757d',\n backgroundColor: 'rgba(108, 117, 125, 0.1)',\n fill: false,\n tension: 0.4,\n },\n {\n label: 'Volume',\n data: volumeData,\n borderColor: '#007bff',\n backgroundColor: 'rgba(0, 123, 255, 0.1)',\n fill: true,\n tension: 0.4,\n },\n ],\n },\n options: {\n responsive: true,\n plugins: {\n title: {\n display: true,\n text: `${symbol} Market Data`,\n },\n },\n scales: {\n y: {\n beginAtZero: false,\n },\n },\n },\n };\n\n chart.setConfig(config);\n\n const imageBuffer = await chart.toDataUrl();\n\n return {\n content: [\n {\n type: 'image',\n data: imageBuffer,\n mimeType: 'image/png',\n },\n ],\n };\n } catch (error) {\n return {\n content: [\n {\n type: 'text',\n text: `Error: ${error instanceof Error ? error.message : 'Failed to generate chart'}`,\n uri: 'getStockGraph',\n },\n ],\n isError: true,\n };\n }\n };\n};\n\nexport const createGetStockPriceHistoryHandler = (\n marketDataPrices: Map<\n string,\n Array<{\n timestamp: number;\n bid: number;\n offer: number;\n spread: number;\n volume: number;\n }>\n >,\n): ((args: { symbol: string }) => Promise<CallToolResult>) => {\n return async (args: { symbol: string }): Promise<CallToolResult> => {\n try {\n const symbol = args.symbol;\n const priceHistory = marketDataPrices.get(symbol) || [];\n\n if (priceHistory.length === 0) {\n return {\n content: [\n {\n type: 'text',\n text: `No price data available for ${symbol}`,\n uri: 'getStockPriceHistory',\n },\n ],\n };\n }\n\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(\n {\n symbol,\n count: priceHistory.length,\n data: priceHistory.map((point) => ({\n timestamp: new Date(point.timestamp).toISOString(),\n bid: point.bid,\n offer: point.offer,\n spread: point.spread,\n volume: point.volume,\n })),\n },\n null,\n 2,\n ),\n uri: 'getStockPriceHistory',\n },\n ],\n };\n } catch (error) {\n return {\n content: [\n {\n type: 'text',\n text: `Error: ${error instanceof Error ? error.message : 'Failed to get stock price history'}`,\n uri: 'getStockPriceHistory',\n },\n ],\n isError: true,\n };\n }\n };\n};\n", "import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';\nimport { Field, Fields, type IFIXParser, type Message, Messages } from 'fixparser';\nimport type { VerifiedOrder } from '../schemas';\n\nconst ordTypeNames: Record<string, string> = {\n '1': 'Market',\n '2': 'Limit',\n '3': 'Stop',\n '4': 'StopLimit',\n '5': 'MarketOnClose',\n '6': 'WithOrWithout',\n '7': 'LimitOrBetter',\n '8': 'LimitWithOrWithout',\n '9': 'OnBasis',\n A: 'OnClose',\n B: 'LimitOnClose',\n C: 'ForexMarket',\n D: 'PreviouslyQuoted',\n E: 'PreviouslyIndicated',\n F: 'ForexLimit',\n G: 'ForexSwap',\n H: 'ForexPreviouslyQuoted',\n I: 'Funari',\n J: 'MarketIfTouched',\n K: 'MarketWithLeftOverAsLimit',\n L: 'PreviousFundValuationPoint',\n M: 'NextFundValuationPoint',\n P: 'Pegged',\n Q: 'CounterOrderSelection',\n R: 'StopOnBidOrOffer',\n S: 'StopLimitOnBidOrOffer',\n};\n\nconst sideNames: Record<string, string> = {\n '1': 'Buy',\n '2': 'Sell',\n '3': 'BuyMinus',\n '4': 'SellPlus',\n '5': 'SellShort',\n '6': 'SellShortExempt',\n '7': 'Undisclosed',\n '8': 'Cross',\n '9': 'CrossShort',\n A: 'CrossShortExempt',\n B: 'AsDefined',\n C: 'Opposite',\n D: 'Subscribe',\n E: 'Redeem',\n F: 'Lend',\n G: 'Borrow',\n H: 'SellUndisclosed',\n};\n\nconst timeInForceNames: Record<string, string> = {\n '0': 'Day',\n '1': 'GoodTillCancel',\n '2': 'AtTheOpening',\n '3': 'ImmediateOrCancel',\n '4': 'FillOrKill',\n '5': 'GoodTillCrossing',\n '6': 'GoodTillDate',\n '7': 'AtTheClose',\n '8': 'GoodThroughCrossing',\n '9': 'AtCrossing',\n A: 'GoodForTime',\n B: 'GoodForAuction',\n C: 'GoodForMonth',\n};\n\nconst handlInstNames: Record<string, string> = {\n '1': 'AutomatedExecutionNoIntervention',\n '2': 'AutomatedExecutionInterventionOK',\n '3': 'ManualOrder',\n};\n\nexport const createVerifyOrderHandler = (\n parser: IFIXParser,\n verifiedOrders: Map<string, VerifiedOrder>,\n): ((args: VerifiedOrder) => Promise<CallToolResult>) => {\n return async (args: VerifiedOrder): Promise<CallToolResult> => {\n try {\n // Store the verified order parameters\n verifiedOrders.set(args.clOrdID, {\n clOrdID: args.clOrdID,\n handlInst: args.handlInst,\n quantity: Number.parseFloat(String(args.quantity)),\n price: Number.parseFloat(String(args.price)),\n ordType: args.ordType,\n side: args.side,\n symbol: args.symbol,\n timeInForce: args.timeInForce,\n });\n\n return {\n content: [\n {\n type: 'text',\n text: `VERIFICATION: All parameters valid. Ready to proceed with order execution.\n \nParameters verified:\n- ClOrdID: ${args.clOrdID}\n- HandlInst: ${args.handlInst} (${handlInstNames[args.handlInst]})\n- Quantity: ${args.quantity}\n- Price: ${args.price}\n- OrdType: ${args.ordType} (${ordTypeNames[args.ordType]})\n- Side: ${args.side} (${sideNames[args.side]})\n- Symbol: ${args.symbol}\n- TimeInForce: ${args.timeInForce} (${timeInForceNames[args.timeInForce]})\n\nTo execute this order, call the executeOrder tool with these exact same parameters.`,\n uri: 'verifyOrder',\n },\n ],\n };\n } catch (error) {\n return {\n content: [\n {\n type: 'text',\n text: `Error: ${error instanceof Error ? error.message : 'Failed to verify order parameters'}`,\n uri: 'verifyOrder',\n },\n ],\n isError: true,\n };\n }\n };\n};\n\nexport const createExecuteOrderHandler = (\n parser: IFIXParser,\n verifiedOrders: Map<string, VerifiedOrder>,\n pendingRequests: Map<string, (data: Message) => void>,\n): ((args: VerifiedOrder) => Promise<CallToolResult>) => {\n return async (args: VerifiedOrder): Promise<CallToolResult> => {\n try {\n // Check if this order was previously verified\n const verifiedOrder = verifiedOrders.get(args.clOrdID);\n if (!verifiedOrder) {\n return {\n content: [\n {\n type: 'text',\n text: `Error: Order ${args.clOrdID} has not been verified. Please call verifyOrder first.`,\n uri: 'executeOrder',\n },\n ],\n isError: true,\n };\n }\n\n // Verify that all parameters match the verified order\n if (\n verifiedOrder.handlInst !== args.handlInst ||\n verifiedOrder.quantity !== Number.parseFloat(String(args.quantity)) ||\n verifiedOrder.price !== Number.parseFloat(String(args.price)) ||\n verifiedOrder.ordType !== args.ordType ||\n verifiedOrder.side !== args.side ||\n verifiedOrder.symbol !== args.symbol ||\n verifiedOrder.timeInForce !== args.timeInForce\n ) {\n return {\n content: [\n {\n type: 'text',\n text: 'Error: Order parameters do not match the verified order. Please use the exact same parameters that were verified.',\n uri: 'executeOrder',\n },\n ],\n isError: true,\n };\n }\n\n const response = new Promise((resolve) => {\n pendingRequests.set(args.clOrdID, resolve);\n });\n\n const order: Message | undefined = parser.createMessage(\n new Field(Fields.MsgType, Messages.NewOrderSingle),\n new Field(Fields.MsgSeqNum, parser.getNextTargetMsgSeqNum()),\n new Field(Fields.SenderCompID, parser.sender),\n new Field(Fields.TargetCompID, parser.target),\n new Field(Fields.SendingTime, parser.getTimestamp()),\n new Field(Fields.ClOrdID, args.clOrdID),\n new Field(Fields.Side, args.side),\n new Field(Fields.Symbol, args.symbol),\n new Field(Fields.OrderQty, Number.parseFloat(String(args.quantity))),\n new Field(Fields.Price, Number.parseFloat(String(args.price))),\n new Field(Fields.OrdType, args.ordType),\n new Field(Fields.HandlInst, args.handlInst),\n new Field(Fields.TimeInForce, args.timeInForce),\n new Field(Fields.TransactTime, parser.getTimestamp()),\n );\n\n if (!parser.connected) {\n return {\n content: [\n {\n type: 'text',\n text: 'Error: Not connected. Ignoring message.',\n uri: 'executeOrder',\n },\n ],\n isError: true,\n };\n }\n\n parser.send(order!);\n\n const fixData = await response;\n\n // Remove the verified order after execution\n verifiedOrders.delete(args.clOrdID);\n\n return {\n content: [\n {\n type: 'text',\n text:\n (fixData as Message).messageType === Messages.Reject\n ? `Reject message for order ${args.clOrdID}: ${JSON.stringify((fixData as Message).toFIXJSON())}`\n : `Execution Report for order ${args.clOrdID}: ${JSON.stringify((fixData as Message).toFIXJSON())}`,\n uri: 'executeOrder',\n },\n ],\n };\n } catch (error) {\n return {\n content: [\n {\n type: 'text',\n text: `Error: ${error instanceof Error ? error.message : 'Failed to execute order'}`,\n uri: 'executeOrder',\n },\n ],\n isError: true,\n };\n }\n };\n};\n", "import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';\nimport type { IFIXParser, Message } from 'fixparser';\n\nexport const createParseHandler = (parser: IFIXParser): ((args: { fixString: string }) => Promise<CallToolResult>) => {\n return async (args: { fixString: string }): Promise<CallToolResult> => {\n try {\n const parsedMessage: Message[] | undefined = parser.parse(args.fixString);\n if (!parsedMessage || parsedMessage.length === 0) {\n return {\n content: [\n {\n type: 'text',\n text: 'Error: Failed to parse FIX string',\n uri: 'parse',\n },\n ],\n isError: true,\n };\n }\n\n return {\n content: [\n {\n type: 'text',\n text: `${parsedMessage[0].description}\\n${parsedMessage[0].messageTypeDescription}`,\n uri: 'parse',\n },\n ],\n };\n } catch (error) {\n return {\n content: [\n {\n type: 'text',\n text: `Error: ${error instanceof Error ? error.message : 'Failed to parse FIX string'}`,\n uri: 'parse',\n },\n ],\n isError: true,\n };\n }\n };\n};\n", "import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';\nimport type { IFIXParser } from 'fixparser';\n\nexport const createParseToJSONHandler = (\n parser: IFIXParser,\n): ((args: { fixString: string }) => Promise<CallToolResult>) => {\n return async (args: { fixString: string }): Promise<CallToolResult> => {\n try {\n const parsedMessage = parser.parse(args.fixString);\n if (!parsedMessage || parsedMessage.length === 0) {\n return {\n content: [\n {\n type: 'text',\n text: 'Error: Failed to parse FIX string',\n uri: 'parseToJSON',\n },\n ],\n isError: true,\n };\n }\n\n return {\n content: [\n {\n type: 'text',\n text: `${parsedMessage[0].toFIXJSON()}`,\n uri: 'parseToJSON',\n },\n ],\n };\n } catch (error) {\n return {\n content: [\n {\n type: 'text',\n text: `Error: ${error instanceof Error ? error.message : 'Failed to parse FIX string'}`,\n uri: 'parseToJSON',\n },\n ],\n isError: true,\n };\n }\n };\n};\n", "import type { IFIXParser, Message } from 'fixparser';\nimport type { ToolHandlers, VerifiedOrder } from '../schemas';\nimport {\n createGetStockGraphHandler,\n createGetStockPriceHistoryHandler,\n createMarketDataRequestHandler,\n} from './marketData';\nimport { createExecuteOrderHandler, createVerifyOrderHandler } from './order';\nimport { createParseHandler } from './parse';\nimport { createParseToJSONHandler } from './parseToJSON';\n\nexport const createToolHandlers = (\n parser: IFIXParser,\n verifiedOrders: Map<string, VerifiedOrder>,\n pendingRequests: Map<string, (data: Message) => void>,\n marketDataPrices: Map<\n string,\n {\n timestamp: number;\n bid: number;\n offer: number;\n spread: number;\n volume: number;\n }[]\n >,\n): ToolHandlers => ({\n parse: createParseHandler(parser),\n parseToJSON: createParseToJSONHandler(parser),\n verifyOrder: createVerifyOrderHandler(parser, verifiedOrders),\n executeOrder: createExecuteOrderHandler(parser, verifiedOrders, pendingRequests),\n marketDataRequest: createMarketDataRequestHandler(parser, pendingRequests),\n getStockGraph: createGetStockGraphHandler(marketDataPrices),\n getStockPriceHistory: createGetStockPriceHistoryHandler(marketDataPrices),\n});\n"],
|
|
5
|
+
"mappings": ";AAAA,OACI,iBAAAA,EACA,aAAAC,EACA,SAAAC,EACA,UAAAC,EACA,kBAAAC,EACA,YAAAC,EAEA,mBAAAC,MACG,YCQA,IAAMC,EAAN,KAAqD,CAChD,OACA,UAER,YAAY,CAAE,OAAAC,EAAS,OAAQ,UAAAC,EAAY,EAAM,EAAmD,CAChG,KAAK,OAASD,EACd,KAAK,UAAYC,CACrB,CAKA,UAAUC,EAA+E,CACrF,KAAK,OAASA,EAA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AS,EAC3B,MAAO,CAAE,KAAM,QAAS,EACxB,QAAS,CACL,KAAM,SACN,KAAM,CACF,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,GACJ,EACA,YACI,mdACR,EACA,KAAM,CACF,KAAM,SACN,KAAM,CAAC,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,GAAG,EAC1F,YACI,4NACR,EACA,OAAQ,CAAE,KAAM,QAAS,EACzB,YAAa,CACT,KAAM,SACN,KAAM,CAAC,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,GAAG,EACtE,YACI,mOACR,CACJ,EACA,SAAU,CAAC,UAAW,YAAa,WAAY,QAAS,UAAW,OAAQ,SAAU,aAAa,CACtG,CACJ,EACA,kBAAmB,CACf,YAAa,6CACb,OAAQ,CACJ,KAAM,SACN,WAAY,CACR,aAAc,CACV,KAAM,SACN,KAAM,CAAC,IAAK,GAAG,EACf,YAAa,gEACjB,EACA,QAAS,CAAE,KAAM,QAAS,MAAO,CAAE,KAAM,QAAS,CAAE,EACpD,QAAS,CAAE,KAAM,QAAS,EAC1B,wBAAyB,CACrB,KAAM,SACN,KAAM,CAAC,IAAK,IAAK,GAAG,EACpB,YACI,2GACR,EACA,aAAc,CACV,KAAM,QACN,MAAO,CACH,KAAM,SACN,KAAM,CACF,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,GACJ,CACJ,EACA,YACI,u0BACR,CACJ,EACA,SAAU,CAAC,eAAgB,UAAW,UAAW,yBAAyB,CAC9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T,CAAM,EACrC,IAAIQ,EAAMC,EAAO,YAAaP,EAAU,aAAa,CAAC,EACtD,IAAIM,EAAMC,EAAO,aAAcR,CAAM,EACrC,IAAIO,EAAMC,EAAO,gBAAiBE,EAAgB,GAAG,EACrD,IAAIH,EAAMC,EAAO,cAAeG,EAAc,IAAI,EAClD,IAAIJ,EAAMC,EAAO,WAAY,EAAE,CACnC,EACAP,EAAU,KAAKK,CAAK,CACxB,EAEMM,EAA0B,CAC5B,KAAM,QAAQ,IAAI,gBAAkB,YACpC,KAAM,QAAQ,IAAI,eAAiB,OAAO,SAAS,QAAQ,IAAI,eAAgB,EAAE,EAAI,KACrF,SAAU,MACV,OAAQb,EACR,OAAQC,EACR,WAAY,UACZ,OAAQ,IAAM,CACVC,EAAU,OAAO,IAAI,CACjB,MAAO,OACP,QAAS,yBACb,CAAC,EACDI,EAAU,CACd,EACA,QAAS,IAAM,CACXJ,EAAU,OAAO,IAAI,CACjB,MAAO,OACP,QAAS,qDACb,CAAC,EACD,WAAW,IAAM,CACbA,EAAU,QAAQW,CAAc,CACpC,EAAG,GAAI,CACX,CACJ,EAEAX,EAAU,QAAQW,CAAc,CACpC,EAEAf,EAAiB,EAAE,MAAOgB,GAAQ,QAAQ,MAAM,6BAA8BA,CAAG,CAAC",
|
|
6
|
+
"names": ["EncryptMethod", "FIXParser", "Field", "Fields", "LicenseManager", "Messages", "ResetSeqNumFlag", "ConsoleLogTransport", "format", "useStderr", "config", "log", "logMethod", "message", "rest", "jsonrpcMessage", "name", "id", "level", "additionalProperties", "kv", "key", "value", "logMessage", "Server", "StdioServerTransport", "Fields", "MDEntryType", "Messages", "z", "Field", "QuickChart", "toolSchemas", "createMarketDataRequestHandler", "parser", "pendingRequests", "args", "response", "resolve", "entryTypes", "messageFields", "symbol", "entryType", "mdr", "fixData", "error", "createGetStockGraphHandler", "marketDataPrices", "priceHistory", "chart", "labels", "point", "bidData", "offerData", "spreadData", "volumeData", "config", "createGetStockPriceHistoryHandler", "ordTypeNames", "sideNames", "timeInForceNames", "handlInstNames", "createVerifyOrderHandler", "verifiedOrders", "createExecuteOrderHandler", "verifiedOrder", "order", "createParseHandler", "parsedMessage", "createParseToJSONHandler", "createToolHandlers", "MCPLocal", "acc", "name", "description", "schema", "logger", "onReady", "message", "msgType", "id", "price", "size", "timestamp", "symbolStr", "priceNum", "sizeNum", "lastEntry", "newEntry", "mdReqID", "clOrdID", "refSeqNum", "callback", "request", "extra", "handler", "result", "initializeServer", "LicenseManager", "SENDER", "TARGET", "fixParser", "FIXParser", "ConsoleLogTransport", "MCPLocal", "sendLogon", "logon", "Field", "Fields", "Messages", "ResetSeqNumFlag", "EncryptMethod", "CONNECT_PARAMS", "err"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fixparser-plugin-mcp",
|
|
3
|
-
"version": "9.1.7-
|
|
4
|
-
"description": "FIXParser MCP
|
|
3
|
+
"version": "9.1.7-fbc175db",
|
|
4
|
+
"description": "FIXParser MCP Plugin (Local/Remote)",
|
|
5
5
|
"files": [
|
|
6
6
|
"./build/",
|
|
7
7
|
"./build-examples/",
|
|
@@ -31,14 +31,14 @@
|
|
|
31
31
|
},
|
|
32
32
|
"author": "Victor Norgren",
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@modelcontextprotocol/sdk": "1.12.
|
|
34
|
+
"@modelcontextprotocol/sdk": "1.12.3",
|
|
35
35
|
"body-parser": "2.2.0",
|
|
36
36
|
"express": "5.1.0",
|
|
37
37
|
"fixparser": "next",
|
|
38
38
|
"fixparser-common": "next",
|
|
39
39
|
"fixparser-plugin-log-console": "next",
|
|
40
|
-
"
|
|
41
|
-
"zod
|
|
40
|
+
"quickchart-js": "3.1.3",
|
|
41
|
+
"zod": "3.25.64"
|
|
42
42
|
},
|
|
43
43
|
"keywords": [
|
|
44
44
|
"FIXParser",
|
|
@@ -62,6 +62,6 @@
|
|
|
62
62
|
}
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@types/express": "5.0.
|
|
65
|
+
"@types/express": "5.0.3"
|
|
66
66
|
}
|
|
67
67
|
}
|
package/types/MCPLocal.d.ts
CHANGED
|
@@ -7,6 +7,9 @@ export declare class MCPLocal implements IPlugin<IFIXParser> {
|
|
|
7
7
|
private transport;
|
|
8
8
|
private onReady;
|
|
9
9
|
private pendingRequests;
|
|
10
|
+
private verifiedOrders;
|
|
11
|
+
private marketDataPrices;
|
|
12
|
+
private readonly MAX_PRICE_HISTORY;
|
|
10
13
|
constructor({ logger, onReady }: PluginOptions);
|
|
11
14
|
register(parser: IFIXParser): Promise<void>;
|
|
12
15
|
private addWorkflows;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
export interface VerifiedOrder {
|
|
3
|
+
clOrdID: string;
|
|
4
|
+
handlInst: string;
|
|
5
|
+
quantity: number;
|
|
6
|
+
price: number;
|
|
7
|
+
ordType: string;
|
|
8
|
+
side: string;
|
|
9
|
+
symbol: string;
|
|
10
|
+
timeInForce: string;
|
|
11
|
+
}
|
|
12
|
+
export type ToolHandler = (args: any) => Promise<CallToolResult>;
|
|
13
|
+
export interface ToolHandlers {
|
|
14
|
+
[key: string]: ToolHandler;
|
|
15
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
export declare const toolSchemas: {
|
|
2
|
+
parse: {
|
|
3
|
+
description: string;
|
|
4
|
+
schema: {
|
|
5
|
+
type: string;
|
|
6
|
+
properties: {
|
|
7
|
+
fixString: {
|
|
8
|
+
type: string;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
required: string[];
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
parseToJSON: {
|
|
15
|
+
description: string;
|
|
16
|
+
schema: {
|
|
17
|
+
type: string;
|
|
18
|
+
properties: {
|
|
19
|
+
fixString: {
|
|
20
|
+
type: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
required: string[];
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
verifyOrder: {
|
|
27
|
+
description: string;
|
|
28
|
+
schema: {
|
|
29
|
+
type: string;
|
|
30
|
+
properties: {
|
|
31
|
+
clOrdID: {
|
|
32
|
+
type: string;
|
|
33
|
+
};
|
|
34
|
+
handlInst: {
|
|
35
|
+
type: string;
|
|
36
|
+
enum: string[];
|
|
37
|
+
description: string;
|
|
38
|
+
};
|
|
39
|
+
quantity: {
|
|
40
|
+
type: string;
|
|
41
|
+
};
|
|
42
|
+
price: {
|
|
43
|
+
type: string;
|
|
44
|
+
};
|
|
45
|
+
ordType: {
|
|
46
|
+
type: string;
|
|
47
|
+
enum: string[];
|
|
48
|
+
description: string;
|
|
49
|
+
};
|
|
50
|
+
side: {
|
|
51
|
+
type: string;
|
|
52
|
+
enum: string[];
|
|
53
|
+
description: string;
|
|
54
|
+
};
|
|
55
|
+
symbol: {
|
|
56
|
+
type: string;
|
|
57
|
+
};
|
|
58
|
+
timeInForce: {
|
|
59
|
+
type: string;
|
|
60
|
+
enum: string[];
|
|
61
|
+
description: string;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
required: string[];
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
executeOrder: {
|
|
68
|
+
description: string;
|
|
69
|
+
schema: {
|
|
70
|
+
type: string;
|
|
71
|
+
properties: {
|
|
72
|
+
clOrdID: {
|
|
73
|
+
type: string;
|
|
74
|
+
};
|
|
75
|
+
handlInst: {
|
|
76
|
+
type: string;
|
|
77
|
+
enum: string[];
|
|
78
|
+
description: string;
|
|
79
|
+
};
|
|
80
|
+
quantity: {
|
|
81
|
+
type: string;
|
|
82
|
+
};
|
|
83
|
+
price: {
|
|
84
|
+
type: string;
|
|
85
|
+
};
|
|
86
|
+
ordType: {
|
|
87
|
+
type: string;
|
|
88
|
+
enum: string[];
|
|
89
|
+
description: string;
|
|
90
|
+
};
|
|
91
|
+
side: {
|
|
92
|
+
type: string;
|
|
93
|
+
enum: string[];
|
|
94
|
+
description: string;
|
|
95
|
+
};
|
|
96
|
+
symbol: {
|
|
97
|
+
type: string;
|
|
98
|
+
};
|
|
99
|
+
timeInForce: {
|
|
100
|
+
type: string;
|
|
101
|
+
enum: string[];
|
|
102
|
+
description: string;
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
required: string[];
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
marketDataRequest: {
|
|
109
|
+
description: string;
|
|
110
|
+
schema: {
|
|
111
|
+
type: string;
|
|
112
|
+
properties: {
|
|
113
|
+
mdUpdateType: {
|
|
114
|
+
type: string;
|
|
115
|
+
enum: string[];
|
|
116
|
+
description: string;
|
|
117
|
+
};
|
|
118
|
+
symbols: {
|
|
119
|
+
type: string;
|
|
120
|
+
items: {
|
|
121
|
+
type: string;
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
mdReqID: {
|
|
125
|
+
type: string;
|
|
126
|
+
};
|
|
127
|
+
subscriptionRequestType: {
|
|
128
|
+
type: string;
|
|
129
|
+
enum: string[];
|
|
130
|
+
description: string;
|
|
131
|
+
};
|
|
132
|
+
mdEntryTypes: {
|
|
133
|
+
type: string;
|
|
134
|
+
items: {
|
|
135
|
+
type: string;
|
|
136
|
+
enum: string[];
|
|
137
|
+
};
|
|
138
|
+
description: string;
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
required: string[];
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
getStockGraph: {
|
|
145
|
+
description: string;
|
|
146
|
+
schema: {
|
|
147
|
+
type: string;
|
|
148
|
+
properties: {
|
|
149
|
+
symbol: {
|
|
150
|
+
type: string;
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
required: string[];
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
getStockPriceHistory: {
|
|
157
|
+
description: string;
|
|
158
|
+
schema: {
|
|
159
|
+
type: string;
|
|
160
|
+
properties: {
|
|
161
|
+
symbol: {
|
|
162
|
+
type: string;
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
required: string[];
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { IFIXParser, Message } from 'fixparser';
|
|
2
|
+
import type { ToolHandlers, VerifiedOrder } from '../schemas';
|
|
3
|
+
export declare const createToolHandlers: (
|
|
4
|
+
parser: IFIXParser,
|
|
5
|
+
verifiedOrders: Map<string, VerifiedOrder>,
|
|
6
|
+
pendingRequests: Map<string, (data: Message) => void>,
|
|
7
|
+
marketDataPrices: Map<
|
|
8
|
+
string,
|
|
9
|
+
{
|
|
10
|
+
timestamp: number;
|
|
11
|
+
bid: number;
|
|
12
|
+
offer: number;
|
|
13
|
+
spread: number;
|
|
14
|
+
volume: number;
|
|
15
|
+
}[]
|
|
16
|
+
>,
|
|
17
|
+
) => ToolHandlers;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
import { type IFIXParser, type Message } from 'fixparser';
|
|
3
|
+
export declare const createMarketDataRequestHandler: (
|
|
4
|
+
parser: IFIXParser,
|
|
5
|
+
pendingRequests: Map<string, (data: Message) => void>,
|
|
6
|
+
) => (args: {
|
|
7
|
+
mdUpdateType: string;
|
|
8
|
+
symbols: string[];
|
|
9
|
+
mdReqID: string;
|
|
10
|
+
subscriptionRequestType: string;
|
|
11
|
+
mdEntryTypes?: string[];
|
|
12
|
+
}) => Promise<CallToolResult>;
|
|
13
|
+
export declare const createGetStockGraphHandler: (
|
|
14
|
+
marketDataPrices: Map<
|
|
15
|
+
string,
|
|
16
|
+
Array<{
|
|
17
|
+
timestamp: number;
|
|
18
|
+
bid: number;
|
|
19
|
+
offer: number;
|
|
20
|
+
spread: number;
|
|
21
|
+
volume: number;
|
|
22
|
+
}>
|
|
23
|
+
>,
|
|
24
|
+
) => (args: {
|
|
25
|
+
symbol: string;
|
|
26
|
+
}) => Promise<CallToolResult>;
|
|
27
|
+
export declare const createGetStockPriceHistoryHandler: (
|
|
28
|
+
marketDataPrices: Map<
|
|
29
|
+
string,
|
|
30
|
+
Array<{
|
|
31
|
+
timestamp: number;
|
|
32
|
+
bid: number;
|
|
33
|
+
offer: number;
|
|
34
|
+
spread: number;
|
|
35
|
+
volume: number;
|
|
36
|
+
}>
|
|
37
|
+
>,
|
|
38
|
+
) => (args: {
|
|
39
|
+
symbol: string;
|
|
40
|
+
}) => Promise<CallToolResult>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
import { type IFIXParser, type Message } from 'fixparser';
|
|
3
|
+
import type { VerifiedOrder } from '../schemas';
|
|
4
|
+
export declare const createVerifyOrderHandler: (
|
|
5
|
+
parser: IFIXParser,
|
|
6
|
+
verifiedOrders: Map<string, VerifiedOrder>,
|
|
7
|
+
) => (args: VerifiedOrder) => Promise<CallToolResult>;
|
|
8
|
+
export declare const createExecuteOrderHandler: (
|
|
9
|
+
parser: IFIXParser,
|
|
10
|
+
verifiedOrders: Map<string, VerifiedOrder>,
|
|
11
|
+
pendingRequests: Map<string, (data: Message) => void>,
|
|
12
|
+
) => (args: VerifiedOrder) => Promise<CallToolResult>;
|