Quant Assistant Agent First Version Summary

The current setup uses the Model Context Protocol (MCP) which is:

  • Request-Response based: Each tool call is a single request that returns a complete response
  • JSON-based messaging: Structured but not optimized for streaming
  • Stdio transport: Communication over stdin/stdout pipes
  • Synchronous by nature: Even with async Python, the protocol itself expects complete responses

Worth noting the system prompt is where lot of editing/polishing is needed:

  • parse user intent system prompt is key
  • {tools_context}
  • decision logic
  • tools selection rules
  • parameter validation and confirmation
  • file input handling
  • portfolio file handling pa tools
  • spar parameter handling
  • univese parameter handling
  • realtioship parameter handling
  • save/export handling
  • response behavior response format
  • EXAMPLES
If the user asks a GENERAL KNOWLEDGE question (about companies, facts, definitions, etc.), respond with: {{"type": "general_answer", "answer": "your answer here"}}
remember previous conversations and use context

Let’s take a deeper look at the fundamental infrastructure, if we need to apply better communication experience for users.

First, I have intelligent_client.py and intelligent_client_tcp.py, let’s compare

spectintelligent_client.pyintelligent_client_tcp.py
MCP TransportSTDIO pipes (subprocess)Raw TCP sockets
ConnectionLocal process spawningNetwork connection
ProtocolMCP over STDIOJSON-RPC over TCP
DeploymentSingle machineDistributed (over VPN)

The key is uses STDIO pipes is for local MCP communication and HTTPS for Azure OpenAI, while the TCP version uses raw TCP sockets for remote MCP communication. At present, for a small team, STDIO is sufficient.

Further, I’d like to explore gRPC over JSON-RPC,

AspectJSON-RPC (Current)gRPC
Message FormatText-based JSONBinary Protocol Buffers
Schema DefinitionLoose/DynamicStrict .proto files
Type SafetyRuntime validationCompile-time validation
PerformanceSlower (JSON parsing)Faster (binary serialization)
Human ReadabilityEasy to debug/inspectRequires tools to inspect
StreamingRequest/Response only4 streaming patterns
Code GenerationManual implementationAuto-generated clients

gRPC is more for performance optimization, hence in my case, json-RPC is a good solution.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.