---
title: "Building an AI Trading Incident Response Agent with TrueForge and MCP"
description: "How we built Sentinel Trading Desk, an AI-powered trading incident response system using TrueForge, MCP, Alpaca, and Qodo."
tags: ai, agents, hackathon, mcp
---
# Building an AI Trading Incident Response Agent with TrueForge and MCP
Hackathons are usually about building something quickly.
For us, the interesting challenge was not simply:
> Can we build an AI agent?
It was:
> Can we build an AI agent that can investigate a trading incident, understand what happened, and safely recommend or execute a response?
That question led us to build **Sentinel Trading Desk**, an AI-powered trading incident response system using TrueForge, MCP, Alpaca, React, and Qodo.
## The Problem
Trading systems generate a large amount of information:
- Account balances
- Open positions
- Recent orders
- Portfolio performance
- Strategy activity
- Unexpected changes in equity
When something goes wrong, a trader or developer may need to manually inspect several sources to understand what happened.
For example:
> Why did the portfolio suddenly lose 3%?
Answering this might require checking positions, recent orders, account state, and historical portfolio performance.
We wanted an agent that could perform this investigation automatically.
However, an AI system with unrestricted access to trading actions introduces another problem: safety.
Our design principle became:
> Investigate automatically. Act with approval.
---
## What We Built
Sentinel Trading Desk is an AI-powered incident response dashboard for paper-trading environments.
A typical investigation follows this workflow:
```text
Trading anomaly detected
|
v
AI agent starts investigation
|
v
Check account state
|
v
Check positions
|
v
Inspect recent orders
|
v
Analyze portfolio history
|
v
Determine likely cause
|
v
Recommend remediation
|
v
Human approval
|
v
Execute approved action
The goal is to turn a complicated trading investigation into a structured workflow.
Architecture
The system consists of three main layers:
+-----------------------------+
| Sentinel UI |
| React + Vite |
+--------------+--------------+
|
v
+-----------------------------+
| TrueForge |
| AI Agent Runtime |
+--------------+--------------+
|
| MCP
v
+-----------------------------+
| Sentinel MCP Server |
+--------------+--------------+
|
v
+-----------------------------+
| Alpaca Trading API |
| Paper Account |
+-----------------------------+
The separation between these components was important.
The UI does not directly manipulate the trading account.
Instead, the system follows:
UI -> TrueForge -> MCP -> Alpaca
This provides the agent with a controlled interface to the trading environment.
How We Used TrueForge
TrueForge is the agent orchestration layer of Sentinel.
We configured a TrueForge agent with access to our Sentinel MCP server.
The MCP server exposes tools including:
get_account
get_positions
get_recent_orders
get_portfolio_history
flatten_position
disable_strategy
The agent starts with read-only investigation tools.
For example:
Agent:
"Investigate the recent portfolio anomaly."
|
v
get_account()
|
v
get_positions()
|
v
get_recent_orders()
|
v
get_portfolio_history()
|
v
Analyze evidence
|
v
Determine likely cause
After analyzing the available information, the agent can recommend a remediation.
Potentially destructive operations require human approval.
This allows the agent to perform investigations autonomously while keeping a human responsible for consequential trading actions.
Why We Used MCP
We used the Model Context Protocol (MCP) as the interface between TrueForge and the trading environment.
Instead of exposing our entire backend to the agent, we expose a limited set of explicit tools.
For example:
const tools = [
"get_account",
"get_positions",
"get_recent_orders",
"get_portfolio_history",
"flatten_position",
"disable_strategy",
];
This gives the agent a clear capability boundary.
The MCP server is independently deployed and authenticated.
The resulting architecture is:
TrueForge Agent
|
| MCP
v
Sentinel MCP Server
|
+---- get_account
+---- get_positions
+---- get_recent_orders
+---- get_portfolio_history
+---- flatten_position
+---- disable_strategy
|
v
Alpaca
Safety and Human Approval
Trading automation requires stronger safety controls than a typical chatbot.
A wrong chatbot response may be inconvenient.
A wrong trading action can have financial consequences.
Therefore, Sentinel follows:
Read-only investigation
|
v
AI analysis
|
v
Proposed remediation
|
v
Human approval
|
v
Action execution
Actions such as:
flatten_position
disable_strategy
require explicit approval.
This gives us a human-in-the-loop control point before consequential operations.
The MCP server is also protected using a shared authentication secret.
Requests to the MCP endpoint must include:
Authorization: Bearer <MCP_SHARED_SECRET>
Using Qodo for Code Quality
We used Qodo as an additional AI-powered code review and quality-assurance layer during development.
Sentinel contains several interacting components:
React UI
|
+-- TrueForge SDK
|
+-- TrueForge Agent
|
+-- MCP Server
|
+-- Alpaca API
|
+-- Authentication
Because failures can occur at the boundaries between these components, code review was particularly important.
Qodo helped us identify issues around:
- Error handling
- Authentication
- API integration
- Input validation
- Edge cases
- Reliability
We applied the suggested fixes and tested the affected functionality again.
This gave us an additional review layer beyond our own testing.
Deployment
We deployed the components as separate services.
Sentinel UI
https://sentinel-ui-pqwl.onrender.com/
TrueForge
https://trueforge.onrender.com/
Sentinel MCP
https://sentinel-alpaca-mcp.onrender.com/mcp
The MCP server also exposes a health endpoint:
https://sentinel-alpaca-mcp.onrender.com/health
A successful health response looks like:
{
"status": "ok"
}
This allows us to independently verify that the MCP service is running.
Debugging During the Hackathon
One of the most useful parts of the project was debugging the deployed system.
The local version worked, but deployment introduced several new problems involving:
- Render configuration
- MCP authentication
- CORS
- TrueForge API routes
- Frontend environment variables
- MCP connector configuration
- SDK compatibility
For example, at one point the browser showed:
sessions 404
preflight CORS
The MCP server itself was healthy and the TrueForge MCP connector showed the available Sentinel tools.
The actual problem was the communication between the Sentinel UI and the hosted TrueForge API.
This was an important lesson:
In distributed AI applications, the model is only one part of the system.
The surrounding infrastructure matters just as much.
Environment Configuration
The deployed Sentinel UI connects to the hosted TrueForge instance using:
VITE_TRUEFORGE_BASE_URL=https://trueforge.onrender.com
TrueForge then connects to the Sentinel MCP endpoint:
https://sentinel-alpaca-mcp.onrender.com/mcp
The MCP server uses a shared secret for authentication:
MCP_SHARED_SECRET=<secret>
The resulting request from TrueForge to the MCP server is:
POST /mcp
Host: sentinel-alpaca-mcp.onrender.com
Authorization: Bearer <MCP_SHARED_SECRET>
This keeps the authentication boundary between TrueForge and the MCP server.
What We Learned
1. Agentic systems need boundaries
Giving an agent access to tools is powerful.
Giving it unrestricted access to consequential actions is risky.
Tool-level permissions and human approval provide important safety boundaries.
2. MCP simplifies integrations
MCP gives us a structured interface between the agent and external capabilities.
Instead of implementing custom integrations for every agent, we can expose well-defined tools through an MCP server.
3. Deployment is part of the engineering problem
A system can work perfectly on localhost and fail after deployment.
Environment variables, authentication, CORS, API routes, and service-to-service communication all become important.
4. Debugging distributed agents requires observability
When an agent fails, "something went wrong" is not enough.
We need to determine:
Which service failed?
Which endpoint was called?
Was authentication successful?
Was the tool available?
What response was returned?
Was the failure in the agent, MCP server, or UI?
This debugging approach was essential during the hackathon.
What's Next
Sentinel currently focuses on paper trading, but the architecture can be extended.
Potential improvements include:
- More sophisticated anomaly detection
- Strategy-level monitoring
- Automated incident classification
- Multi-agent investigations
- Portfolio risk analysis
- More granular approval policies
- Detailed audit logs
- Additional trading integrations
The long-term goal is not simply to build an AI that can trade.
It is to build an AI-powered trading operations layer that helps humans understand what is happening in their systems and respond safely.
Final Thoughts
This hackathon showed us that building an AI agent is not just about connecting an LLM to a few tools.
The difficult engineering happens around the agent:
Tool design
+
Permissions
+
Authentication
+
Deployment
+
Observability
+
Error handling
+
Human oversight
With Sentinel Trading Desk, we wanted to explore what an AI-native trading incident response system could look like.
TrueForge provides the agent orchestration layer.
MCP provides a structured interface to the trading environment.
Alpaca provides the trading infrastructure.
Qodo provides an additional layer of code review and quality assurance.
The result is an AI agent that can investigate trading incidents, explain what happened, and help determine what to do next while keeping humans in control of consequential actions.
Project
GitHub:
https://github.com/siddarth709/trading-desk-sentinel
Live UI:
https://sentinel-ui-pqwl.onrender.com/
MCP Server:
https://sentinel-alpaca-mcp.onrender.com/mcp
Top comments (0)