fixparser-plugin-mcp 9.1.7-27ef5b7b → 9.1.7-28bfe28b
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";var r=require("fixparser");var w=require("@modelcontextprotocol/sdk/server/index.js"),T=require("@modelcontextprotocol/sdk/server/stdio.js"),c=require("@modelcontextprotocol/sdk/types.js"),e=require("fixparser"),S={type:"object",properties:{fixString:{type:"string",description:"FIX message string to parse"}},required:["fixString"]},f={type:"object",properties:{fixString:{type:"string",description:"FIX message string to parse"}},required:["fixString"]},I={type:"object",properties:{clOrdID:{type:"string",description:"Client Order ID"},handlInst:{type:"string",enum:["1","2","3"],default:e.HandlInst.AutomatedExecutionNoIntervention,description:"Handling instruction"},quantity:{type:"number",description:"Order quantity"},price:{type:"number",description:"Order price"},ordType:{type:"string",enum:["1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","P","Q","R","S"],default:e.OrdType.Market,description:"Order type"},side:{type:"string",enum:["1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H"],description:"Order side (1=Buy, 2=Sell)"},symbol:{type:"string",description:"Trading symbol"},timeInForce:{type:"string",enum:["0","1","2","3","4","5","6","7","8","9","A","B","C"],default:e.TimeInForce.Day,description:"Time in force"}},required:["clOrdID","quantity","price","side","symbol"]},q={type:"object",properties:{mdUpdateType:{type:"string",enum:["0","1"],default:"0",description:"Market data update type"},symbol:{type:"string",description:"Trading symbol"},mdReqID:{type:"string",description:"Market data request ID"},subscriptionRequestType:{type:"string",enum:["0","1","2"],default:e.SubscriptionRequestType.SnapshotAndUpdates,description:"Subscription request type"},mdEntryType:{type:"string",enum:["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","J","K","L","M","N","O","P","Q","S","R","T","U","V","W","X","Y","Z","a","b","c","d","e","g","h","i","t"],default:e.MDEntryType.Bid,description:"Market data entry type"}},required:["symbol","mdReqID"]},F=class{logger;parser;server=new w.Server({name:"fixparser",version:"1.0.0"},{capabilities:{tools:{},prompts:{},resources:{}}});transport=new T.StdioServerTransport;onReady=void 0;pendingRequests=new Map;constructor({logger:n,onReady:a}){n&&(this.logger=n),a&&(this.onReady=a)}async register(n){this.parser=n,this.parser.addOnMessageCallback(a=>{this.logger?.log({level:"info",message:`FIXParser (MCP): (${n.protocol?.toUpperCase()}): << received ${a.description}`});let o=a.messageType;if(o===e.Messages.MarketDataSnapshotFullRefresh||o===e.Messages.ExecutionReport){let i=o===e.Messages.MarketDataSnapshotFullRefresh?a.getField(e.Fields.MDReqID):a.getField(e.Fields.ClOrdID);if(i){let t=i.value;if(typeof t=="string"||typeof t=="number"){let s=this.pendingRequests.get(String(t));s&&(s(a),this.pendingRequests.delete(String(t)))}}}}),this.logger=n.logger,this.addWorkflows(),await this.server.connect(this.transport),this.onReady&&this.onReady()}addWorkflows(){if(!this.parser){this.logger?.log({level:"error",message:"FIXParser (MCP): -- FIXParser instance not initialized. Ignoring setup of workflows..."});return}if(!this.server){this.logger?.log({level:"error",message:"FIXParser (MCP): -- MCP Server not initialized. Ignoring setup of workflows..."});return}let n=(a,o)=>{let i={};for(let[t,s]of Object.entries(o.properties||{})){let p=s,d=a?.[t];if(p.required&&d==null)throw new Error(`Required property '${t}' is missing`);d!==void 0?i[t]=d:p.default!==void 0&&(i[t]=p.default)}return i};this.server.setRequestHandler(c.ListResourcesRequestSchema,async()=>({resources:[]})),this.server.setRequestHandler(c.ListToolsRequestSchema,async()=>({tools:[{name:"parse",description:"Parses a FIX message and describes it in plain language",inputSchema:S},{name:"parseToJSON",description:"Parses a FIX message into JSON",inputSchema:f},{name:"newOrderSingle",description:"Creates and sends a New Order Single",inputSchema:I},{name:"marketDataRequest",description:"Sends a request for Market Data with the given symbol",inputSchema:q}]})),this.server.setRequestHandler(c.CallToolRequestSchema,async a=>{let{name:o,arguments:i}=a.params;switch(o){case"parse":try{let{fixString:t}=n(i,S),s=this.parser?.parse(t);return!s||s.length===0?{isError:!0,content:[{type:"text",text:"Error: Failed to parse FIX string"}]}:{content:[{type:"text",text:`Parsed FIX message: ${t} (placeholder implementation)`}]}}catch(t){return{isError:!0,content:[{type:"text",text:`Error: ${t instanceof Error?t.message:"Failed to parse FIX string"}`}]}}case"parseToJSON":try{let{fixString:t}=n(i,f),s=this.parser?.parse(t);return!s||s.length===0?{isError:!0,content:[{type:"text",text:"Error: Failed to parse FIX string"}]}:{content:[{type:"text",text:JSON.stringify({fixString:t,parsed:"placeholder"})}]}}catch(t){return{isError:!0,content:[{type:"text",text:`Error: ${t instanceof Error?t.message:"Failed to parse FIX string"}`}]}}case"newOrderSingle":try{let{clOrdID:t,handlInst:s,quantity:p,price:d,ordType:g,side:u,symbol:l,timeInForce:m}=n(i,I),y=new Promise(x=>{this.pendingRequests.set(t,x)}),h=this.parser?.createMessage(new e.Field(e.Fields.MsgType,e.Messages.NewOrderSingle),new e.Field(e.Fields.MsgSeqNum,this.parser?.getNextTargetMsgSeqNum()),new e.Field(e.Fields.SenderCompID,this.parser?.sender),new e.Field(e.Fields.TargetCompID,this.parser?.target),new e.Field(e.Fields.SendingTime,this.parser?.getTimestamp()),new e.Field(e.Fields.ClOrdID,t),new e.Field(e.Fields.Side,u),new e.Field(e.Fields.Symbol,l),new e.Field(e.Fields.OrderQty,p),new e.Field(e.Fields.Price,d),new e.Field(e.Fields.OrdType,g),new e.Field(e.Fields.HandlInst,s),new e.Field(e.Fields.TimeInForce,m),new e.Field(e.Fields.TransactTime,this.parser?.getTimestamp()));if(!this.parser?.connected)return this.logger?.log({level:"error",message:"FIXParser (MCP): -- Not connected. Ignoring message."}),{isError:!0,content:[{type:"text",text:"Error: Not connected. Ignoring message."}]};this.parser?.send(h),this.logger?.log({level:"info",message:`FIXParser (MCP): (${this.parser?.protocol?.toUpperCase()}): >> sent ${h?.description}`});let M=await y;return{content:[{type:"text",text:`Execution Report for order ${t}: ${JSON.stringify(M.toFIXJSON())}`}]}}catch(t){return{isError:!0,content:[{type:"text",text:`Error: ${t instanceof Error?t.message:"Failed to create order"}`}]}}case"marketDataRequest":try{let{mdUpdateType:t,symbol:s,mdReqID:p,subscriptionRequestType:d,mdEntryType:g}=n(i,q),u=new Promise(y=>{this.pendingRequests.set(p,y)}),l=this.parser?.createMessage(new e.Field(e.Fields.MsgType,e.Messages.MarketDataRequest),new e.Field(e.Fields.SenderCompID,this.parser?.sender),new e.Field(e.Fields.MsgSeqNum,this.parser?.getNextTargetMsgSeqNum()),new e.Field(e.Fields.TargetCompID,this.parser?.target),new e.Field(e.Fields.SendingTime,this.parser?.getTimestamp()),new e.Field(e.Fields.MarketDepth,0),new e.Field(e.Fields.MDUpdateType,t),new e.Field(e.Fields.NoRelatedSym,1),new e.Field(e.Fields.Symbol,s),new e.Field(e.Fields.MDReqID,p),new e.Field(e.Fields.SubscriptionRequestType,d),new e.Field(e.Fields.NoMDEntryTypes,1),new e.Field(e.Fields.MDEntryType,g));if(!this.parser?.connected)return this.logger?.log({level:"error",message:"FIXParser (MCP): -- Not connected. Ignoring message."}),{isError:!0,content:[{type:"text",text:"Error: Not connected. Ignoring message."}]};this.parser?.send(l),this.logger?.log({level:"info",message:`FIXParser (MCP): (${this.parser?.protocol?.toUpperCase()}): >> sent ${l?.description}`});let m=await u;return{content:[{type:"text",text:`Market data for ${s}: ${JSON.stringify(m.toFIXJSON())}`}]}}catch(t){return{isError:!0,content:[{type:"text",text:`Error: ${t instanceof Error?t.message:"Failed to request market data"}`}]}}default:throw new Error(`Unknown tool: ${o}`)}}),this.server.setRequestHandler(c.ListPromptsRequestSchema,async()=>({prompts:[{name:"parse",description:"Parses a FIX message and describes it in plain language",arguments:[{name:"fixString",description:"FIX message string to parse",required:!0}]},{name:"parseToJSON",description:"Parses a FIX message into JSON",arguments:[{name:"fixString",description:"FIX message string to parse",required:!0}]},{name:"newOrderSingle",description:"Creates and sends a New Order Single",arguments:[{name:"clOrdID",description:"Client Order ID",required:!0},{name:"handlInst",description:"Handling instruction",required:!1},{name:"quantity",description:"Order quantity",required:!0},{name:"price",description:"Order price",required:!0},{name:"ordType",description:"Order type",required:!1},{name:"side",description:"Order side (1=Buy, 2=Sell)",required:!0},{name:"symbol",description:"Trading symbol",required:!0},{name:"timeInForce",description:"Time in force",required:!1}]},{name:"marketDataRequest",description:"Sends a request for Market Data with the given symbol",arguments:[{name:"mdUpdateType",description:"Market data update type",required:!1},{name:"symbol",description:"Trading symbol",required:!0},{name:"mdReqID",description:"Market data request ID",required:!0},{name:"subscriptionRequestType",description:"Subscription request type",required:!1},{name:"mdEntryType",description:"Market data entry type",required:!1}]}]})),this.server.setRequestHandler(c.GetPromptRequestSchema,async a=>{let{name:o,arguments:i}=a.params;switch(o){case"parse":return{messages:[{role:"user",content:{type:"text",text:`Please parse and explain this FIX message: ${i?.fixString||""}`}}]};case"parseToJSON":return{messages:[{role:"user",content:{type:"text",text:`Please parse the FIX message to JSON: ${i?.fixString||""}`}}]};case"newOrderSingle":{let{clOrdID:t,handlInst:s,quantity:p,price:d,ordType:g,side:u,symbol:l,timeInForce:m}=i||{};return{messages:[{role:"user",content:{type:"text",text:["Create a New Order Single FIX message with the following parameters:",`- ClOrdID: ${t}`,`- HandlInst: ${s??"default"}`,`- Quantity: ${p}`,`- Price: ${d}`,`- OrdType: ${g??"default (Market)"}`,`- Side: ${u}`,`- Symbol: ${l}`,`- TimeInForce: ${m??"default (Day)"}`,"","Format the response as a JSON object with FIX tag numbers as keys and their corresponding values."].join(`
|
|
3
3
|
`)}}]}}case"marketDataRequest":{let{mdUpdateType:t,symbol:s,mdReqID:p,subscriptionRequestType:d,mdEntryType:g}=i||{};return{messages:[{role:"user",content:{type:"text",text:["Create a Market Data Request FIX message with the following parameters:",`- MDUpdateType: ${t??"default (0 = FullRefresh)"}`,`- Symbol: ${s}`,`- MDReqID: ${p}`,`- SubscriptionRequestType: ${d??"default (0 = Snapshot + Updates)"}`,`- MDEntryType: ${g??"default (0 = Bid)"}`,"","Format the response as a JSON object with FIX tag numbers as keys and their corresponding values."].join(`
|
|
4
|
-
`)}}]}}default:throw new Error(`Unknown prompt: ${o}`)}}),process.on("SIGINT",async()=>{await this.server.close(),process.exit(0)})}};var R=async()=>{await r.LicenseManager.setLicenseKey(process.env.FIXPARSER_LICENSE_KEY);let n=new r.FIXParser({plugins:[new F({port:3099,onReady:()=>{}})]}),a=()=>{let s=n.createMessage(new r.Field(r.Fields.MsgType,r.Messages.Logon),new r.Field(r.Fields.MsgSeqNum,n.getNextTargetMsgSeqNum()),new r.Field(r.Fields.SenderCompID,o),new r.Field(r.Fields.SendingTime,n.getTimestamp()),new r.Field(r.Fields.TargetCompID,i),new r.Field(r.Fields.ResetSeqNumFlag,r.ResetSeqNumFlag.Yes),new r.Field(r.Fields.EncryptMethod,r.EncryptMethod.None),new r.Field(r.Fields.HeartBtInt,10));n.send(s)},o="CLIENT2",i="EXECUTOR",t={host:"
|
|
4
|
+
`)}}]}}default:throw new Error(`Unknown prompt: ${o}`)}}),process.on("SIGINT",async()=>{await this.server.close(),process.exit(0)})}};var R=async()=>{await r.LicenseManager.setLicenseKey(process.env.FIXPARSER_LICENSE_KEY);let n=new r.FIXParser({plugins:[new F({port:3099,onReady:()=>{}})]}),a=()=>{let s=n.createMessage(new r.Field(r.Fields.MsgType,r.Messages.Logon),new r.Field(r.Fields.MsgSeqNum,n.getNextTargetMsgSeqNum()),new r.Field(r.Fields.SenderCompID,o),new r.Field(r.Fields.SendingTime,n.getTimestamp()),new r.Field(r.Fields.TargetCompID,i),new r.Field(r.Fields.ResetSeqNumFlag,r.ResetSeqNumFlag.Yes),new r.Field(r.Fields.EncryptMethod,r.EncryptMethod.None),new r.Field(r.Fields.HeartBtInt,10));n.send(s)},o="CLIENT2",i="EXECUTOR",t={host:"10.0.1.42",port:5001,protocol:"tcp",sender:o,target:i,fixVersion:"FIX.4.4",logging:!1,onOpen:()=>{a()},onMessage:s=>{},onClose:()=>{}};n.connect(t)};R().catch(n=>console.error("Error initializing server:",n));
|
|
5
5
|
//# sourceMappingURL=example_mcp_local.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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 initializeServer = async () => {\n await LicenseManager.setLicenseKey(process.env.FIXPARSER_LICENSE_KEY);\n\n const fixParser: FIXParser = new FIXParser({\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 SENDER = 'CLIENT2';\n const TARGET = 'EXECUTOR';\n const CONNECT_PARAMS: Options = {\n host: 'localhost',\n port: 5001,\n protocol: 'tcp',\n sender: SENDER,\n target: TARGET,\n fixVersion: 'FIX.4.4',\n logging: false,\n onOpen: () => {\n sendLogon();\n },\n onMessage: (message: Message) => {},\n onClose: () => {},\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 {\n Field,\n Fields,\n HandlInst,\n type IFIXParser,\n type Logger,\n MDEntryType,\n type Message,\n Messages,\n OrdType,\n SubscriptionRequestType,\n TimeInForce,\n} 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 default: HandlInst.AutomatedExecutionNoIntervention,\n description: 'Handling instruction',\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 default: OrdType.Market,\n description: 'Order type',\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: 'Order side (1=Buy, 2=Sell)',\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 default: TimeInForce.Day,\n description: 'Time in force',\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 default: '0',\n description: 'Market data update type',\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 default: SubscriptionRequestType.SnapshotAndUpdates,\n description: 'Subscription request type',\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 default: MDEntryType.Bid,\n description: 'Market data entry type',\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 (logger) this.logger = logger;\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 (msgType === Messages.MarketDataSnapshotFullRefresh || msgType === Messages.ExecutionReport) {\n const idField =\n msgType === Messages.MarketDataSnapshotFullRefresh\n ? message.getField(Fields.MDReqID)\n : message.getField(Fields.ClOrdID);\n if (idField) {\n const id = idField.value;\n if (typeof id === 'string' || typeof id === 'number') {\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 this.logger = parser.logger;\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 = 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: `Parsed FIX message: ${fixString} (placeholder implementation)`,\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: JSON.stringify({ fixString, parsed: 'placeholder' }),\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 return {\n content: [\n {\n type: 'text',\n text: `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: false,\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: false,\n },\n {\n name: 'side',\n description: 'Order side (1=Buy, 2=Sell)',\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: false,\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: false,\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: false,\n },\n {\n name: 'mdEntryType',\n description: 'Market data entry type',\n required: false,\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 ?? 'default'}`,\n `- Quantity: ${quantity}`,\n `- Price: ${price}`,\n `- OrdType: ${ordType ?? 'default (Market)'}`,\n `- Side: ${side}`,\n `- Symbol: ${symbol}`,\n `- TimeInForce: ${timeInForce ?? 'default (Day)'}`,\n '',\n 'Format the response as a JSON object with FIX tag numbers as keys and their corresponding values.',\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 ?? 'default (0 = FullRefresh)'}`,\n `- Symbol: ${symbol}`,\n `- MDReqID: ${mdReqID}`,\n `- SubscriptionRequestType: ${subscriptionRequestType ?? 'default (0 = Snapshot + Updates)'}`,\n `- MDEntryType: ${mdEntryType ?? 'default (0 = Bid)'}`,\n '',\n 'Format the response as a JSON object with FIX tag numbers as keys and their corresponding values.',\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"],
|
|
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 initializeServer = async () => {\n await LicenseManager.setLicenseKey(process.env.FIXPARSER_LICENSE_KEY);\n\n const fixParser: FIXParser = new FIXParser({\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 SENDER = 'CLIENT2';\n const TARGET = 'EXECUTOR';\n const CONNECT_PARAMS: Options = {\n host: '10.0.1.42',\n port: 5001,\n protocol: 'tcp',\n sender: SENDER,\n target: TARGET,\n fixVersion: 'FIX.4.4',\n logging: false,\n onOpen: () => {\n sendLogon();\n },\n onMessage: (message: Message) => {},\n onClose: () => {},\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 {\n Field,\n Fields,\n HandlInst,\n type IFIXParser,\n type Logger,\n MDEntryType,\n type Message,\n Messages,\n OrdType,\n SubscriptionRequestType,\n TimeInForce,\n} 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 default: HandlInst.AutomatedExecutionNoIntervention,\n description: 'Handling instruction',\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 default: OrdType.Market,\n description: 'Order type',\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: 'Order side (1=Buy, 2=Sell)',\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 default: TimeInForce.Day,\n description: 'Time in force',\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 default: '0',\n description: 'Market data update type',\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 default: SubscriptionRequestType.SnapshotAndUpdates,\n description: 'Subscription request type',\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 default: MDEntryType.Bid,\n description: 'Market data entry type',\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 (logger) this.logger = logger;\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 (msgType === Messages.MarketDataSnapshotFullRefresh || msgType === Messages.ExecutionReport) {\n const idField =\n msgType === Messages.MarketDataSnapshotFullRefresh\n ? message.getField(Fields.MDReqID)\n : message.getField(Fields.ClOrdID);\n if (idField) {\n const id = idField.value;\n if (typeof id === 'string' || typeof id === 'number') {\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 this.logger = parser.logger;\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 = 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: `Parsed FIX message: ${fixString} (placeholder implementation)`,\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: JSON.stringify({ fixString, parsed: 'placeholder' }),\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 return {\n content: [\n {\n type: 'text',\n text: `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: false,\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: false,\n },\n {\n name: 'side',\n description: 'Order side (1=Buy, 2=Sell)',\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: false,\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: false,\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: false,\n },\n {\n name: 'mdEntryType',\n description: 'Market data entry type',\n required: false,\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 ?? 'default'}`,\n `- Quantity: ${quantity}`,\n `- Price: ${price}`,\n `- OrdType: ${ordType ?? 'default (Market)'}`,\n `- Side: ${side}`,\n `- Symbol: ${symbol}`,\n `- TimeInForce: ${timeInForce ?? 'default (Day)'}`,\n '',\n 'Format the response as a JSON object with FIX tag numbers as keys and their corresponding values.',\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 ?? 'default (0 = FullRefresh)'}`,\n `- Symbol: ${symbol}`,\n `- MDReqID: ${mdReqID}`,\n `- SubscriptionRequestType: ${subscriptionRequestType ?? 'default (0 = Snapshot + Updates)'}`,\n `- MDEntryType: ${mdEntryType ?? 'default (0 = Bid)'}`,\n '',\n 'Format the response as a JSON object with FIX tag numbers as keys and their corresponding values.',\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
5
|
"mappings": ";aAAA,IAAAA,EAUO,qBCVP,IAAAC,EAAuB,qDACvBC,EAAqC,qDACrCC,EAMO,8CAEPC,EAYO,qBAKDC,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,QAAS,YAAU,iCACnB,YAAa,sBACjB,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,QAAS,UAAQ,OACjB,YAAa,YACjB,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,YAAa,4BACjB,EACA,OAAQ,CACJ,KAAM,SACN,YAAa,gBACjB,EACA,YAAa,CACT,KAAM,SACN,KAAM,CAAC,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,GAAG,EACtE,QAAS,cAAY,IACrB,YAAa,eACjB,CACJ,EACA,SAAU,CAAC,UAAW,WAAY,QAAS,OAAQ,QAAQ,CAC/D,EAEMC,EAA+B,CACjC,KAAM,SACN,WAAY,CACR,aAAc,CACV,KAAM,SACN,KAAM,CAAC,IAAK,GAAG,EACf,QAAS,IACT,YAAa,yBACjB,EACA,OAAQ,CACJ,KAAM,SACN,YAAa,gBACjB,EACA,QAAS,CACL,KAAM,SACN,YAAa,wBACjB,EACA,wBAAyB,CACrB,KAAM,SACN,KAAM,CAAC,IAAK,IAAK,GAAG,EACpB,QAAS,0BAAwB,mBACjC,YAAa,2BACjB,EACA,YAAa,CACT,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,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,GACJ,EACA,QAAS,cAAY,IACrB,YAAa,wBACjB,CACJ,EACA,SAAU,CAAC,SAAU,SAAS,CAClC,EAEaC,EAAN,KAA8C,CACzC,OACA,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AAS,CACL,CACI,KAAM,QACN,YAAa,0DACb,UAAW,CACP,CACI,KAAM,YACN,YAAa,8BACb,SAAU,EACd,CACJ,CACJ,EACA,CACI,KAAM,cACN,YAAa,iCACb,UAAW,CACP,CACI,KAAM,YACN,YAAa,8BACb,SAAU,EACd,CACJ,CACJ,EACA,CACI,KAAM,iBACN,YAAa,uCACb,UAAW,CACP,CACI,KAAM,UACN,YAAa,kBACb,SAAU,EACd,EACA,CACI,KAAM,YACN,YAAa,uBACb,SAAU,EACd,EACA,CACI,KAAM,WACN,YAAa,iBACb,SAAU,EACd,EACA,CACI,KAAM,QACN,YAAa,cACb,SAAU,EACd,EACA,CACI,KAAM,UACN,YAAa,aACb,SAAU,EACd,EACA,CACI,KAAM,OACN,YAAa,6BACb,SAAU,EACd,EACA,CACI,KAAM,SACN,YAAa,iBACb,SAAU,EACd,EACA,CACI,KAAM,cACN,YAAa,gBACb,SAAU,EACd,CACJ,CACJ,EACA,CACI,KAAM,oBACN,YAAa,wDACb,UAAW,CACP,CACI,KAAM,eACN,YAAa,0BACb,SAAU,EACd,EACA,CACI,KAAM,SACN,YAAa,iBACb,SAAU,EACd,EACA,CACI,KAAM,UACN,YAAa,yBACb,SAAU,EACd,EACA,CACI,KAAM,0BACN,YAAa,4BACb,SAAU,EACd,EACA,CACI,KAAM,cACN,YAAa,yBACb,SAAU,EACd,CACJ,CACJ,CACJ,CACJ,EACH,EAGD,KAAK,OAAO,kBAAkB,yBAAwB,MAAOD,GAAY,CACrE,GAAM,CAAE,KAAAC,EAAM,UAAWR,CAAK,EAAIO,EAAQ,OAE1C,OAAQC,EAAM,CACV,IAAK,QAED,MAAO,CACH,SAAU,CACN,CACI,KAAM,OACN,QAAS,CACL,KAAM,OACN,KAAM,8CAPJR,GAAM,WAAa,EAOwC,EACjE,CACJ,CACJ,CACJ,EAGJ,IAAK,cAED,MAAO,CACH,SAAU,CACN,CACI,KAAM,OACN,QAAS,CACL,KAAM,OACN,KAAM,yCAPJA,GAAM,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AS,CAAC,IAAIC,EAAS,CAAE,KAAM,KAAM,QAAS,IAAM,CAAC,CAAE,CAAC,CAAC,CAC7D,CAAC,EAEKC,EAAY,IAAM,CACpB,IAAMC,EAAQH,EAAU,cACpB,IAAI,QAAM,SAAO,QAAS,WAAS,KAAK,EACxC,IAAI,QAAM,SAAO,UAAWA,EAAU,uBAAuB,CAAC,EAC9D,IAAI,QAAM,SAAO,aAAcI,CAAM,EACrC,IAAI,QAAM,SAAO,YAAaJ,EAAU,aAAa,CAAC,EACtD,IAAI,QAAM,SAAO,aAAcK,CAAM,EACrC,IAAI,QAAM,SAAO,gBAAiB,kBAAgB,GAAG,EACrD,IAAI,QAAM,SAAO,cAAe,gBAAc,IAAI,EAClD,IAAI,QAAM,SAAO,WAAY,EAAE,CACnC,EACAL,EAAU,KAAKG,CAAK,CACxB,EAEMC,EAAS,UACTC,EAAS,WACTC,EAA0B,CAC5B,KAAM,YACN,KAAM,KACN,SAAU,MACV,OAAQF,EACR,OAAQC,EACR,WAAY,UACZ,QAAS,GACT,OAAQ,IAAM,CACVH,EAAU,CACd,EACA,UAAYK,GAAqB,CAAC,EAClC,QAAS,IAAM,CAAC,CACpB,EAEAP,EAAU,QAAQM,CAAc,CACpC,EAEAP,EAAiB,EAAE,MAAOS,GAAQ,QAAQ,MAAM,6BAA8BA,CAAG,CAAC",
|
|
6
6
|
"names": ["import_fixparser", "import_server", "import_stdio", "import_types", "import_fixparser", "parseInputSchema", "parseToJSONInputSchema", "newOrderSingleInputSchema", "marketDataRequestInputSchema", "MCPLocal", "logger", "onReady", "parser", "message", "msgType", "idField", "id", "callback", "validateArgs", "args", "schema", "result", "key", "propSchema", "prop", "value", "request", "name", "fixString", "parsedMessage", "error", "clOrdID", "handlInst", "quantity", "price", "ordType", "side", "symbol", "timeInForce", "response", "resolve", "order", "fixData", "mdUpdateType", "mdReqID", "subscriptionRequestType", "mdEntryType", "marketDataRequest", "initializeServer", "fixParser", "MCPLocal", "sendLogon", "logon", "SENDER", "TARGET", "CONNECT_PARAMS", "message", "err"]
|
|
7
7
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import{EncryptMethod as J,FIXParser as U,Field as c,Fields as g,LicenseManager as H,Messages as L,ResetSeqNumFlag as A}from"fixparser";import{Server as R}from"@modelcontextprotocol/sdk/server/index.js";import{StdioServerTransport as D}from"@modelcontextprotocol/sdk/server/stdio.js";import{CallToolRequestSchema as O,GetPromptRequestSchema as E,ListPromptsRequestSchema as b,ListResourcesRequestSchema as N,ListToolsRequestSchema as v}from"@modelcontextprotocol/sdk/types.js";import{Field as r,Fields as t,HandlInst as C,MDEntryType as P,Messages as h,OrdType as X,SubscriptionRequestType as k,TimeInForce as $}from"fixparser";var I={type:"object",properties:{fixString:{type:"string",description:"FIX message string to parse"}},required:["fixString"]},q={type:"object",properties:{fixString:{type:"string",description:"FIX message string to parse"}},required:["fixString"]},w={type:"object",properties:{clOrdID:{type:"string",description:"Client Order ID"},handlInst:{type:"string",enum:["1","2","3"],default:C.AutomatedExecutionNoIntervention,description:"Handling instruction"},quantity:{type:"number",description:"Order quantity"},price:{type:"number",description:"Order price"},ordType:{type:"string",enum:["1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","P","Q","R","S"],default:X.Market,description:"Order type"},side:{type:"string",enum:["1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H"],description:"Order side (1=Buy, 2=Sell)"},symbol:{type:"string",description:"Trading symbol"},timeInForce:{type:"string",enum:["0","1","2","3","4","5","6","7","8","9","A","B","C"],default:$.Day,description:"Time in force"}},required:["clOrdID","quantity","price","side","symbol"]},T={type:"object",properties:{mdUpdateType:{type:"string",enum:["0","1"],default:"0",description:"Market data update type"},symbol:{type:"string",description:"Trading symbol"},mdReqID:{type:"string",description:"Market data request ID"},subscriptionRequestType:{type:"string",enum:["0","1","2"],default:k.SnapshotAndUpdates,description:"Subscription request type"},mdEntryType:{type:"string",enum:["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","J","K","L","M","N","O","P","Q","S","R","T","U","V","W","X","Y","Z","a","b","c","d","e","g","h","i","t"],default:P.Bid,description:"Market data entry type"}},required:["symbol","mdReqID"]},F=class{logger;parser;server=new R({name:"fixparser",version:"1.0.0"},{capabilities:{tools:{},prompts:{},resources:{}}});transport=new D;onReady=void 0;pendingRequests=new Map;constructor({logger:n,onReady:a}){n&&(this.logger=n),a&&(this.onReady=a)}async register(n){this.parser=n,this.parser.addOnMessageCallback(a=>{this.logger?.log({level:"info",message:`FIXParser (MCP): (${n.protocol?.toUpperCase()}): << received ${a.description}`});let o=a.messageType;if(o===h.MarketDataSnapshotFullRefresh||o===h.ExecutionReport){let i=o===h.MarketDataSnapshotFullRefresh?a.getField(t.MDReqID):a.getField(t.ClOrdID);if(i){let e=i.value;if(typeof e=="string"||typeof e=="number"){let s=this.pendingRequests.get(String(e));s&&(s(a),this.pendingRequests.delete(String(e)))}}}}),this.logger=n.logger,this.addWorkflows(),await this.server.connect(this.transport),this.onReady&&this.onReady()}addWorkflows(){if(!this.parser){this.logger?.log({level:"error",message:"FIXParser (MCP): -- FIXParser instance not initialized. Ignoring setup of workflows..."});return}if(!this.server){this.logger?.log({level:"error",message:"FIXParser (MCP): -- MCP Server not initialized. Ignoring setup of workflows..."});return}let n=(a,o)=>{let i={};for(let[e,s]of Object.entries(o.properties||{})){let p=s,d=a?.[e];if(p.required&&d==null)throw new Error(`Required property '${e}' is missing`);d!==void 0?i[e]=d:p.default!==void 0&&(i[e]=p.default)}return i};this.server.setRequestHandler(N,async()=>({resources:[]})),this.server.setRequestHandler(v,async()=>({tools:[{name:"parse",description:"Parses a FIX message and describes it in plain language",inputSchema:I},{name:"parseToJSON",description:"Parses a FIX message into JSON",inputSchema:q},{name:"newOrderSingle",description:"Creates and sends a New Order Single",inputSchema:w},{name:"marketDataRequest",description:"Sends a request for Market Data with the given symbol",inputSchema:T}]})),this.server.setRequestHandler(O,async a=>{let{name:o,arguments:i}=a.params;switch(o){case"parse":try{let{fixString:e}=n(i,I),s=this.parser?.parse(e);return!s||s.length===0?{isError:!0,content:[{type:"text",text:"Error: Failed to parse FIX string"}]}:{content:[{type:"text",text:`Parsed FIX message: ${e} (placeholder implementation)`}]}}catch(e){return{isError:!0,content:[{type:"text",text:`Error: ${e instanceof Error?e.message:"Failed to parse FIX string"}`}]}}case"parseToJSON":try{let{fixString:e}=n(i,q),s=this.parser?.parse(e);return!s||s.length===0?{isError:!0,content:[{type:"text",text:"Error: Failed to parse FIX string"}]}:{content:[{type:"text",text:JSON.stringify({fixString:e,parsed:"placeholder"})}]}}catch(e){return{isError:!0,content:[{type:"text",text:`Error: ${e instanceof Error?e.message:"Failed to parse FIX string"}`}]}}case"newOrderSingle":try{let{clOrdID:e,handlInst:s,quantity:p,price:d,ordType:l,side:m,symbol:u,timeInForce:y}=n(i,w),S=new Promise(x=>{this.pendingRequests.set(e,x)}),f=this.parser?.createMessage(new r(t.MsgType,h.NewOrderSingle),new r(t.MsgSeqNum,this.parser?.getNextTargetMsgSeqNum()),new r(t.SenderCompID,this.parser?.sender),new r(t.TargetCompID,this.parser?.target),new r(t.SendingTime,this.parser?.getTimestamp()),new r(t.ClOrdID,e),new r(t.Side,m),new r(t.Symbol,u),new r(t.OrderQty,p),new r(t.Price,d),new r(t.OrdType,l),new r(t.HandlInst,s),new r(t.TimeInForce,y),new r(t.TransactTime,this.parser?.getTimestamp()));if(!this.parser?.connected)return this.logger?.log({level:"error",message:"FIXParser (MCP): -- Not connected. Ignoring message."}),{isError:!0,content:[{type:"text",text:"Error: Not connected. Ignoring message."}]};this.parser?.send(f),this.logger?.log({level:"info",message:`FIXParser (MCP): (${this.parser?.protocol?.toUpperCase()}): >> sent ${f?.description}`});let M=await S;return{content:[{type:"text",text:`Execution Report for order ${e}: ${JSON.stringify(M.toFIXJSON())}`}]}}catch(e){return{isError:!0,content:[{type:"text",text:`Error: ${e instanceof Error?e.message:"Failed to create order"}`}]}}case"marketDataRequest":try{let{mdUpdateType:e,symbol:s,mdReqID:p,subscriptionRequestType:d,mdEntryType:l}=n(i,T),m=new Promise(S=>{this.pendingRequests.set(p,S)}),u=this.parser?.createMessage(new r(t.MsgType,h.MarketDataRequest),new r(t.SenderCompID,this.parser?.sender),new r(t.MsgSeqNum,this.parser?.getNextTargetMsgSeqNum()),new r(t.TargetCompID,this.parser?.target),new r(t.SendingTime,this.parser?.getTimestamp()),new r(t.MarketDepth,0),new r(t.MDUpdateType,e),new r(t.NoRelatedSym,1),new r(t.Symbol,s),new r(t.MDReqID,p),new r(t.SubscriptionRequestType,d),new r(t.NoMDEntryTypes,1),new r(t.MDEntryType,l));if(!this.parser?.connected)return this.logger?.log({level:"error",message:"FIXParser (MCP): -- Not connected. Ignoring message."}),{isError:!0,content:[{type:"text",text:"Error: Not connected. Ignoring message."}]};this.parser?.send(u),this.logger?.log({level:"info",message:`FIXParser (MCP): (${this.parser?.protocol?.toUpperCase()}): >> sent ${u?.description}`});let y=await m;return{content:[{type:"text",text:`Market data for ${s}: ${JSON.stringify(y.toFIXJSON())}`}]}}catch(e){return{isError:!0,content:[{type:"text",text:`Error: ${e instanceof Error?e.message:"Failed to request market data"}`}]}}default:throw new Error(`Unknown tool: ${o}`)}}),this.server.setRequestHandler(b,async()=>({prompts:[{name:"parse",description:"Parses a FIX message and describes it in plain language",arguments:[{name:"fixString",description:"FIX message string to parse",required:!0}]},{name:"parseToJSON",description:"Parses a FIX message into JSON",arguments:[{name:"fixString",description:"FIX message string to parse",required:!0}]},{name:"newOrderSingle",description:"Creates and sends a New Order Single",arguments:[{name:"clOrdID",description:"Client Order ID",required:!0},{name:"handlInst",description:"Handling instruction",required:!1},{name:"quantity",description:"Order quantity",required:!0},{name:"price",description:"Order price",required:!0},{name:"ordType",description:"Order type",required:!1},{name:"side",description:"Order side (1=Buy, 2=Sell)",required:!0},{name:"symbol",description:"Trading symbol",required:!0},{name:"timeInForce",description:"Time in force",required:!1}]},{name:"marketDataRequest",description:"Sends a request for Market Data with the given symbol",arguments:[{name:"mdUpdateType",description:"Market data update type",required:!1},{name:"symbol",description:"Trading symbol",required:!0},{name:"mdReqID",description:"Market data request ID",required:!0},{name:"subscriptionRequestType",description:"Subscription request type",required:!1},{name:"mdEntryType",description:"Market data entry type",required:!1}]}]})),this.server.setRequestHandler(E,async a=>{let{name:o,arguments:i}=a.params;switch(o){case"parse":return{messages:[{role:"user",content:{type:"text",text:`Please parse and explain this FIX message: ${i?.fixString||""}`}}]};case"parseToJSON":return{messages:[{role:"user",content:{type:"text",text:`Please parse the FIX message to JSON: ${i?.fixString||""}`}}]};case"newOrderSingle":{let{clOrdID:e,handlInst:s,quantity:p,price:d,ordType:l,side:m,symbol:u,timeInForce:y}=i||{};return{messages:[{role:"user",content:{type:"text",text:["Create a New Order Single FIX message with the following parameters:",`- ClOrdID: ${e}`,`- HandlInst: ${s??"default"}`,`- Quantity: ${p}`,`- Price: ${d}`,`- OrdType: ${l??"default (Market)"}`,`- Side: ${m}`,`- Symbol: ${u}`,`- TimeInForce: ${y??"default (Day)"}`,"","Format the response as a JSON object with FIX tag numbers as keys and their corresponding values."].join(`
|
|
3
3
|
`)}}]}}case"marketDataRequest":{let{mdUpdateType:e,symbol:s,mdReqID:p,subscriptionRequestType:d,mdEntryType:l}=i||{};return{messages:[{role:"user",content:{type:"text",text:["Create a Market Data Request FIX message with the following parameters:",`- MDUpdateType: ${e??"default (0 = FullRefresh)"}`,`- Symbol: ${s}`,`- MDReqID: ${p}`,`- SubscriptionRequestType: ${d??"default (0 = Snapshot + Updates)"}`,`- MDEntryType: ${l??"default (0 = Bid)"}`,"","Format the response as a JSON object with FIX tag numbers as keys and their corresponding values."].join(`
|
|
4
|
-
`)}}]}}default:throw new Error(`Unknown prompt: ${o}`)}}),process.on("SIGINT",async()=>{await this.server.close(),process.exit(0)})}};var j=async()=>{await H.setLicenseKey(process.env.FIXPARSER_LICENSE_KEY);let n=new U({plugins:[new F({port:3099,onReady:()=>{}})]}),a=()=>{let s=n.createMessage(new c(g.MsgType,L.Logon),new c(g.MsgSeqNum,n.getNextTargetMsgSeqNum()),new c(g.SenderCompID,o),new c(g.SendingTime,n.getTimestamp()),new c(g.TargetCompID,i),new c(g.ResetSeqNumFlag,A.Yes),new c(g.EncryptMethod,J.None),new c(g.HeartBtInt,10));n.send(s)},o="CLIENT2",i="EXECUTOR",e={host:"
|
|
4
|
+
`)}}]}}default:throw new Error(`Unknown prompt: ${o}`)}}),process.on("SIGINT",async()=>{await this.server.close(),process.exit(0)})}};var j=async()=>{await H.setLicenseKey(process.env.FIXPARSER_LICENSE_KEY);let n=new U({plugins:[new F({port:3099,onReady:()=>{}})]}),a=()=>{let s=n.createMessage(new c(g.MsgType,L.Logon),new c(g.MsgSeqNum,n.getNextTargetMsgSeqNum()),new c(g.SenderCompID,o),new c(g.SendingTime,n.getTimestamp()),new c(g.TargetCompID,i),new c(g.ResetSeqNumFlag,A.Yes),new c(g.EncryptMethod,J.None),new c(g.HeartBtInt,10));n.send(s)},o="CLIENT2",i="EXECUTOR",e={host:"10.0.1.42",port:5001,protocol:"tcp",sender:o,target:i,fixVersion:"FIX.4.4",logging:!1,onOpen:()=>{a()},onMessage:s=>{},onClose:()=>{}};n.connect(e)};j().catch(n=>console.error("Error initializing server:",n));
|
|
5
5
|
//# sourceMappingURL=example_mcp_local.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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 initializeServer = async () => {\n await LicenseManager.setLicenseKey(process.env.FIXPARSER_LICENSE_KEY);\n\n const fixParser: FIXParser = new FIXParser({\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 SENDER = 'CLIENT2';\n const TARGET = 'EXECUTOR';\n const CONNECT_PARAMS: Options = {\n host: 'localhost',\n port: 5001,\n protocol: 'tcp',\n sender: SENDER,\n target: TARGET,\n fixVersion: 'FIX.4.4',\n logging: false,\n onOpen: () => {\n sendLogon();\n },\n onMessage: (message: Message) => {},\n onClose: () => {},\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 {\n Field,\n Fields,\n HandlInst,\n type IFIXParser,\n type Logger,\n MDEntryType,\n type Message,\n Messages,\n OrdType,\n SubscriptionRequestType,\n TimeInForce,\n} 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 default: HandlInst.AutomatedExecutionNoIntervention,\n description: 'Handling instruction',\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 default: OrdType.Market,\n description: 'Order type',\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: 'Order side (1=Buy, 2=Sell)',\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 default: TimeInForce.Day,\n description: 'Time in force',\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 default: '0',\n description: 'Market data update type',\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 default: SubscriptionRequestType.SnapshotAndUpdates,\n description: 'Subscription request type',\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 default: MDEntryType.Bid,\n description: 'Market data entry type',\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 (logger) this.logger = logger;\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 (msgType === Messages.MarketDataSnapshotFullRefresh || msgType === Messages.ExecutionReport) {\n const idField =\n msgType === Messages.MarketDataSnapshotFullRefresh\n ? message.getField(Fields.MDReqID)\n : message.getField(Fields.ClOrdID);\n if (idField) {\n const id = idField.value;\n if (typeof id === 'string' || typeof id === 'number') {\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 this.logger = parser.logger;\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 = 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: `Parsed FIX message: ${fixString} (placeholder implementation)`,\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: JSON.stringify({ fixString, parsed: 'placeholder' }),\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 return {\n content: [\n {\n type: 'text',\n text: `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: false,\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: false,\n },\n {\n name: 'side',\n description: 'Order side (1=Buy, 2=Sell)',\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: false,\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: false,\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: false,\n },\n {\n name: 'mdEntryType',\n description: 'Market data entry type',\n required: false,\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 ?? 'default'}`,\n `- Quantity: ${quantity}`,\n `- Price: ${price}`,\n `- OrdType: ${ordType ?? 'default (Market)'}`,\n `- Side: ${side}`,\n `- Symbol: ${symbol}`,\n `- TimeInForce: ${timeInForce ?? 'default (Day)'}`,\n '',\n 'Format the response as a JSON object with FIX tag numbers as keys and their corresponding values.',\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 ?? 'default (0 = FullRefresh)'}`,\n `- Symbol: ${symbol}`,\n `- MDReqID: ${mdReqID}`,\n `- SubscriptionRequestType: ${subscriptionRequestType ?? 'default (0 = Snapshot + Updates)'}`,\n `- MDEntryType: ${mdEntryType ?? 'default (0 = Bid)'}`,\n '',\n 'Format the response as a JSON object with FIX tag numbers as keys and their corresponding values.',\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"],
|
|
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 initializeServer = async () => {\n await LicenseManager.setLicenseKey(process.env.FIXPARSER_LICENSE_KEY);\n\n const fixParser: FIXParser = new FIXParser({\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 SENDER = 'CLIENT2';\n const TARGET = 'EXECUTOR';\n const CONNECT_PARAMS: Options = {\n host: '10.0.1.42',\n port: 5001,\n protocol: 'tcp',\n sender: SENDER,\n target: TARGET,\n fixVersion: 'FIX.4.4',\n logging: false,\n onOpen: () => {\n sendLogon();\n },\n onMessage: (message: Message) => {},\n onClose: () => {},\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 {\n Field,\n Fields,\n HandlInst,\n type IFIXParser,\n type Logger,\n MDEntryType,\n type Message,\n Messages,\n OrdType,\n SubscriptionRequestType,\n TimeInForce,\n} 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 default: HandlInst.AutomatedExecutionNoIntervention,\n description: 'Handling instruction',\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 default: OrdType.Market,\n description: 'Order type',\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: 'Order side (1=Buy, 2=Sell)',\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 default: TimeInForce.Day,\n description: 'Time in force',\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 default: '0',\n description: 'Market data update type',\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 default: SubscriptionRequestType.SnapshotAndUpdates,\n description: 'Subscription request type',\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 default: MDEntryType.Bid,\n description: 'Market data entry type',\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 (logger) this.logger = logger;\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 (msgType === Messages.MarketDataSnapshotFullRefresh || msgType === Messages.ExecutionReport) {\n const idField =\n msgType === Messages.MarketDataSnapshotFullRefresh\n ? message.getField(Fields.MDReqID)\n : message.getField(Fields.ClOrdID);\n if (idField) {\n const id = idField.value;\n if (typeof id === 'string' || typeof id === 'number') {\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 this.logger = parser.logger;\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 = 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: `Parsed FIX message: ${fixString} (placeholder implementation)`,\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: JSON.stringify({ fixString, parsed: 'placeholder' }),\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 return {\n content: [\n {\n type: 'text',\n text: `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: false,\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: false,\n },\n {\n name: 'side',\n description: 'Order side (1=Buy, 2=Sell)',\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: false,\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: false,\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: false,\n },\n {\n name: 'mdEntryType',\n description: 'Market data entry type',\n required: false,\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 ?? 'default'}`,\n `- Quantity: ${quantity}`,\n `- Price: ${price}`,\n `- OrdType: ${ordType ?? 'default (Market)'}`,\n `- Side: ${side}`,\n `- Symbol: ${symbol}`,\n `- TimeInForce: ${timeInForce ?? 'default (Day)'}`,\n '',\n 'Format the response as a JSON object with FIX tag numbers as keys and their corresponding values.',\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 ?? 'default (0 = FullRefresh)'}`,\n `- Symbol: ${symbol}`,\n `- MDReqID: ${mdReqID}`,\n `- SubscriptionRequestType: ${subscriptionRequestType ?? 'default (0 = Snapshot + Updates)'}`,\n `- MDEntryType: ${mdEntryType ?? 'default (0 = Bid)'}`,\n '',\n 'Format the response as a JSON object with FIX tag numbers as keys and their corresponding values.',\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
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,OACI,SAAAC,EACA,UAAAC,EACA,aAAAC,EAGA,eAAAC,EAEA,YAAAC,EACA,WAAAC,EACA,2BAAAC,EACA,eAAAC,MACG,YAKP,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,QAASR,EAAU,iCACnB,YAAa,sBACjB,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,QAASG,EAAQ,OACjB,YAAa,YACjB,EACA,KAAM,CACF,KAAM,SACN,KAAM,CAAC,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AY,IAAM,CACpB,IAAMC,EAAQJ,EAAU,cACpB,IAAIK,EAAMC,EAAO,QAASC,EAAS,KAAK,EACxC,IAAIF,EAAMC,EAAO,UAAWN,EAAU,uBAAuB,CAAC,EAC9D,IAAIK,EAAMC,EAAO,aAAcE,CAAM,EACrC,IAAIH,EAAMC,EAAO,YAAaN,EAAU,aAAa,CAAC,EACtD,IAAIK,EAAMC,EAAO,aAAcG,CAAM,EACrC,IAAIJ,EAAMC,EAAO,gBAAiBI,EAAgB,GAAG,EACrD,IAAIL,EAAMC,EAAO,cAAeK,EAAc,IAAI,EAClD,IAAIN,EAAMC,EAAO,WAAY,EAAE,CACnC,EACAN,EAAU,KAAKI,CAAK,CACxB,EAEMI,EAAS,UACTC,EAAS,WACTG,EAA0B,CAC5B,KAAM,YACN,KAAM,KACN,SAAU,MACV,OAAQJ,EACR,OAAQC,EACR,WAAY,UACZ,QAAS,GACT,OAAQ,IAAM,CACVN,EAAU,CACd,EACA,UAAYU,GAAqB,CAAC,EAClC,QAAS,IAAM,CAAC,CACpB,EAEAb,EAAU,QAAQY,CAAc,CACpC,EAEAd,EAAiB,EAAE,MAAOgB,GAAQ,QAAQ,MAAM,6BAA8BA,CAAG,CAAC",
|
|
6
6
|
"names": ["EncryptMethod", "FIXParser", "Field", "Fields", "LicenseManager", "Messages", "ResetSeqNumFlag", "Server", "StdioServerTransport", "CallToolRequestSchema", "GetPromptRequestSchema", "ListPromptsRequestSchema", "ListResourcesRequestSchema", "ListToolsRequestSchema", "Field", "Fields", "HandlInst", "MDEntryType", "Messages", "OrdType", "SubscriptionRequestType", "TimeInForce", "parseInputSchema", "parseToJSONInputSchema", "newOrderSingleInputSchema", "marketDataRequestInputSchema", "MCPLocal", "logger", "onReady", "parser", "message", "msgType", "idField", "id", "callback", "validateArgs", "args", "schema", "result", "key", "propSchema", "prop", "value", "request", "name", "fixString", "parsedMessage", "error", "clOrdID", "handlInst", "quantity", "price", "ordType", "side", "symbol", "timeInForce", "response", "resolve", "order", "fixData", "mdUpdateType", "mdReqID", "subscriptionRequestType", "mdEntryType", "marketDataRequest", "initializeServer", "LicenseManager", "fixParser", "FIXParser", "MCPLocal", "sendLogon", "logon", "Field", "Fields", "Messages", "SENDER", "TARGET", "ResetSeqNumFlag", "EncryptMethod", "CONNECT_PARAMS", "message", "err"]
|
|
7
7
|
}
|
package/package.json
CHANGED