MCP Server
Overview
Section titled “Overview”The MCP Server is a Model Context Protocol (MCP) server that enables AI models to securely interact with the VETA trading platform. It provides standardised access to market data, order management, analytics, and trading signals.
MCP (Model Context Protocol) is an open standard that enables AI models to securely connect to external data sources and tools. It provides a standardised way for:
- Tools — Functions the AI can invoke (e.g.,
get_market_data,calculate_option_price) - Resources — Data the AI can read (e.g., live market data, portfolio summaries)
- Prompts — Predefined conversation templates for common workflows
Architecture
Section titled “Architecture”graph LR subgraph "AI Model" A["Claude / GPT / etc."] end
subgraph "MCP Server" B["MCP Server<br/>(Deno/Node)"] C["Tools"] D["Resources"] E["Prompts"] end
subgraph "VETA Platform" F["Market Data Service"] G["OMS"] H["EMS"] I["Analytics"] J["Signal Engine"] end
A <-->|"JSON-RPC<br/>stdio / HTTP"| B B --> C B --> D B --> E C --> F C --> G C --> H C --> I C --> J D --> F D --> G E --> JGetting Started
Section titled “Getting Started”Prerequisites
Section titled “Prerequisites”- Deno 1.40+
- Node.js 18+ (optional, for npm dependencies)
Installation
Section titled “Installation”cd backend/mcp-serverdeno installRunning the Server
Section titled “Running the Server”deno run --allow-all src/server.tsThe server will start and listen for MCP requests via stdio.
Testing
Section titled “Testing”deno test --allow-all tests/Available Tools
Section titled “Available Tools”The MCP server exposes the following tools that AI models can invoke:
1. get_market_data
Section titled “1. get_market_data”Get current market data for a trading symbol.
Parameters:
symbol(string): Trading symbol (e.g., "AAPL", "GOOGL")
Example:
{ "name": "get_market_data", "arguments": { "symbol": "AAPL" }}Response:
{ "symbol": "AAPL", "bid": 178.50, "ask": 178.55, "last": 178.52, "volume": 45230000, "timestamp": "2024-01-01T00:00:00.000Z"}2. list_orders
Section titled “2. list_orders”List all orders with their current status.
Parameters: None
Response:
[ { "orderId": "ORD-001", "symbol": "AAPL", "side": "buy", "quantity": 100, "status": "filled", "fillPrice": 178.45 }]3. get_trading_signals
Section titled “3. get_trading_signals”Get current trading signals from the intelligence pipeline.
Parameters: None
Response:
[ { "symbol": "AAPL", "direction": "bullish", "confidence": 0.78, "reason": "Positive momentum with increasing volume" }]4. calculate_option_price
Section titled “4. calculate_option_price”Calculate option price using the Black-Scholes model.
Parameters:
underlyingPrice(number): Current price of the underlying assetstrikePrice(number): Option strike pricetimeToExpiry(number): Time to expiry in yearsvolatility(number): Annualised volatility (e.g., 0.25 for 25%)riskFreeRate(number): Risk-free interest rate (e.g., 0.05 for 5%)optionType(string): "call" or "put"
Response:
{ "optionType": "call", "underlyingPrice": 178.52, "strikePrice": 180, "timeToExpiry": 0.25, "volatility": 0.25, "riskFreeRate": 0.05, "theoreticalPrice": 5.23}Available Resources
Section titled “Available Resources”Resources allow AI models to read data without invoking a tool.
1. veta://market_data/{symbol}
Section titled “1. veta://market_data/{symbol}”Market data for a specific symbol.
Example:
GET veta://market_data/AAPL2. veta://portfolio_summary
Section titled “2. veta://portfolio_summary”Summary of the trading portfolio.
Example:
GET veta://portfolio_summaryAvailable Prompts
Section titled “Available Prompts”Prompts are predefined conversation templates.
1. market_analysis
Section titled “1. market_analysis”Analyze market conditions for a given symbol.
Parameters:
symbol(string): The trading symbol to analyze
Usage:
PROMPT market_analysis { symbol: "AAPL" }How MCP Benefits the VETA Platform
Section titled “How MCP Benefits the VETA Platform”-
Standardised AI Integration — MCP provides a protocol-agnostic way to connect AI models to your trading infrastructure without custom integrations for each model.
-
Security — MCP enforces permission boundaries. You can control which AI models can access which tools and resources.
-
Composability — Multiple MCP servers can expose different domains (market data, risk, orders) independently.
-
Future-Proof — As AI models evolve, MCP ensures your platform remains compatible without code changes.
-
Type Safety — MCP uses JSON Schema for tool parameters, ensuring type safety and validation.
Integration with VETA Panels
Section titled “Integration with VETA Panels”The MCP server can be integrated with VETA panels to provide AI-powered features:
trade-recommendationpanel: Useget_trading_signalsto get AI-driven recommendationsorder-ticketpanel: Usecalculate_option_priceto suggest optimal order parametersrisk-dashboardpanel: Uselist_ordersto monitor order riskmarket-ladderpanel: Useget_market_datato display real-time data
Extending the MCP Server
Section titled “Extending the MCP Server”To add new tools, resources, or prompts:
Adding a Tool
Section titled “Adding a Tool”server.tool( "tool_name", "Tool description", { param1: z.string().describe("Parameter description"), }, async ({ param1 }) => { return { content: [ { type: "text", text: JSON.stringify(result), }, ], }; });Adding a Resource
Section titled “Adding a Resource”server.resource( "resource_name", "veta://resource_name/{param}", async (uri) => { const param = uri.pathname.split("/").pop(); return { contents: [ { uri: uri.href, name: "Resource Name", mimeType: "application/json", text: JSON.stringify(data), }, ], }; });Adding a Prompt
Section titled “Adding a Prompt”server.prompt( "prompt_name", "Prompt description", { param: { description: "Parameter description", required: true, }, }, ({ param }) => { return { messages: [ { role: "user", content: { type: "text", text: `Analyze ${param}`, }, }, ], }; });Transport Options
Section titled “Transport Options”The server currently uses stdio transport (standard input/output), which is ideal for local tools. For production use, you can switch to HTTP transport:
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";import { Hono } from "hono";
const app = new Hono();const server = new McpServer({ name: "veta", version: "1.0.0" });
app.post("/mcp", async (c) => { const body = await c.req.json(); const response = await server.handleRequest(body); return c.json(response);});
app.listen(3001);Licence
Section titled “Licence”MIT