Portfolio API for AI Agents: Building with Claude, ChatGPT, and Gemini
How to integrate CASParser with AI agents using the MCP server, Agent Toolkit, and REST API. Build AI-powered fintech features.
AI Agents Need Portfolio Data
AI agents are increasingly being used in fintech - from portfolio analysis to tax planning to investment advice. But they need structured portfolio data to work with. CASParser provides the bridge between raw financial documents and AI-ready structured data.
Three Ways to Integrate
1. MCP Server (Recommended for AI Agents)
The Model Context Protocol (MCP) server provides 17 live API tools that AI agents can call directly. Works with Claude Code, Cursor, Windsurf, and VS Code.
Setup for Claude Code:
claude mcp add cas_parser_node_mcp \
-e CAS_PARSER_API_KEY=your-api-key \
-- npx -y cas-parser-node-mcp@latest
Setup for Cursor/VS Code (mcp.json):
{
"mcpServers": {
"cas_parser_node_mcp": {
"command": "npx",
"args": ["-y", "cas-parser-node-mcp@latest"],
"env": {
"CAS_PARSER_API_KEY": "your-api-key"
}
}
}
}
The MCP server includes Code Mode - agents can write TypeScript SDK code that runs in a sandboxed environment.
2. Agent Toolkit
Install ready-to-use templates and domain knowledge for AI coding agents:
npx skills add casparser/agent-toolkit
This installs:
- AGENTS.md - Complete integration rules and API reference
- SKILL.md - Domain knowledge and code templates
- 14 code templates - Python, Node.js, React, HTML, curl examples
- OpenAPI spec - Machine-readable API definition
3. REST API (Direct Integration)
For custom AI agent implementations, use the REST API directly:
import requests
response = requests.post(
"https://api.casparser.in/v4/smart/parse",
headers={"x-api-key": "YOUR_API_KEY"},
files={"pdf_file": open("cas.pdf", "rb")},
data={"password": "encrypted_pan"}
)
portfolio = response.json()
Use Cases for AI + Portfolio Data
Portfolio Analysis
AI agents can analyze extracted portfolio data to identify:
- Asset allocation imbalances
- Concentration risk
- Underperforming holdings
- Tax-loss harvesting opportunities
Tax Planning
With complete transaction history (50+ years from CAMS/KFintech), AI agents can:
- Derive capital gains (STCG/LTCG) from transaction data
- Suggest tax-efficient redemption strategies
- Generate tax reports
Client Onboarding
AI agents can automate wealth management onboarding:
- Parse uploaded CAS statements
- Generate portfolio summaries
- Identify investment gaps
- Suggest personalized recommendations
Investment Research
Combine portfolio data with market data for:
- Performance attribution
- Benchmark comparison
- Risk analysis
India PortfolioGPT
CASParser also offers a custom ChatGPT - India PortfolioGPT - that can answer questions about Indian portfolio data, CAS formats, and CASParser integration.
Getting Started
- Get an API key (free tier available)
- Use sandbox key
sandbox-with-json-responsesfor testing - Install the Agent Toolkit or set up the MCP server
- Read the API documentation