Financial Portfolios AI
Systematic model portfolios: allocations, holdings history, model-alignment arithmetic, research.
Install
mcp_config.json
{
"mcpServers": {
"ai-financial-portfolios-financial-portfolios-ai": {
"url": "https://financial-portfolios.ai/mcp",
"type": "streamable-http"
}
}
}Documentation
Financial Portfolios AI Model Context Protocol (MCP) Server
Official Model Context Protocol (MCP) server for Financial Portfolios AI.
This MCP server connects Claude, ChatGPT, and Google Gemini directly to institutional-grade quantitative portfolio strategies, target asset allocation snapshots, portfolio rebalancing engine, and proprietary quantitative research.
Universal Architecture Overview
┌────────────────────────────────────────────────────────────────────────┐
│ AI Ecosystem: Claude · ChatGPT · Gemini · Cursor · Windsurf │
└───────────────────────────────────┬────────────────────────────────────┘
│
MCP / OpenAPI Protocols (HTTP / stdio)
│
┌───────────────────────────────────▼────────────────────────────────────┐
│ Financial Portfolios AI MCP Server (Google Cloud Run) │
└───────────────────────────────────┬────────────────────────────────────┘
│
REST & WebSocket API
│
┌───────────────────────────────────▼────────────────────────────────────┐
│ Customer Portal Backend (https://financial-portfolios.ai) │
└────────────────────────────────────────────────────────────────────────┘
- Remote MCP (Claude Connectors & ChatGPT Apps): Streamable HTTP (
/mcp) and Server-Sent Events (/sse), hosted on Google Cloud Run. - OpenAPI REST Actions (ChatGPT Custom GPTs & Google Vertex AI): Defined via
openapi.yaml. - Local MCP (Claude Desktop, Gemini CLI, Cursor, Windsurf): Runs via standard I/O (
stdio).
Authentication
- Visit financial-portfolios.ai and sign in using Google Social Login (or email credentials).
- Go to Settings > API Tokens (or financial-portfolios.ai/api-access).
- Click Generate API Token.
- Copy your token (starts with
aqat_v1_...).
Multi-Platform Ecosystem Setup
1. Claude AI (claude.ai Connectors & Claude Desktop)
- Claude Web Custom Connector:
- Go to Customize > Connectors -> Add custom connector.
- Enter the server URL
https://financial-portfolios.ai/mcpand sign in when prompted. Authentication is OAuth 2.1 - there is no API key to paste. A tokenless request is answered with a401+WWW-Authenticate: Bearer resource_metadata=...(RFC 9728), which is what starts the sign-in flow. - Command-line clients (Claude Code) do not run that flow: they pass a personal token as
an
X-API-Keyheader instead (see Authentication).
- Directory Manifest: Uses
claude_connector.json. - Claude Desktop Config: See
clients/mcp_clients.dev.jsonorclients/mcp_clients.prod.jsonforclaude_desktop_config.json- pick the deployment you are installing against.
2. OpenAI ChatGPT (Custom GPTs & MCP Apps)
- ChatGPT Custom GPT Actions (GPT Store):
- Open ChatGPT GPT Builder -> Configure -> Actions -> Create new action.
- Paste the contents of
openapi.yaml. - Under Authentication, choose API Key, Auth Type: Custom, Header Name:
X-API-Key.
- ChatGPT MCP Apps (Enterprise & Workspace):
- Add Remote MCP endpoint
https://<your-cloud-run-domain>/mcpwithchatgpt_manifest.json.
- Add Remote MCP endpoint
3. Google Gemini & Google Cloud Vertex AI
- Gemini CLI extension (the supported path):
gemini-extension.jsonwithGEMINI.mdas its context file. Installed from a public repository withgemini extensions install <repo-url>, thengemini extensions config financial-portfolios-aito set the API token. Gemini CLI renders no MCP Apps, so the app tools that only open a UI are excluded and the rest answer as JSON. - Gemini CLI, configured by hand:
gemini mcp add -t http fpai https://<your-domain>/mcp -H "X-API-Key: $FINANCIAL_PORTFOLIOS_API_TOKEN"
4. Developer IDEs (Cursor & Windsurf)
- Cursor IDE (
.cursor/mcp.json):{ "mcpServers": { "fpai": { "url": "https://<your-cloud-run-domain>/mcp", "headers": { "X-API-Key": "aqat_v1_your_token_here" } } } } - Windsurf IDE (
~/.codeium/windsurf/mcp_config.json): Seeclients/mcp_clients.dev.jsonorclients/mcp_clients.prod.json.
Capabilities Reference
🛠️ Tools
| Tool Name | Description | Arguments |
|---|---|---|
open_portfolio_explorer | Interactive (MCP App). Portfolio dropdown, sortable holdings, sector and concentration charts, and changes over time, rendered inline in Claude. | portfolio_code (optional) |
list_portfolios | List every active quantitative portfolio, each marked access = subscribed or public_delayed. | api_token (optional) |
get_portfolio_allocation | Retrieve a target allocation snapshot: the latest book when subscribed, otherwise the public book delayed ~45 days. | portfolio_code, as_of (optional), api_token (optional) |
get_portfolio_history | Retrieve historical allocation timeline for up to 365 days (delayed entries only for non-subscribers). | portfolio_code, days (1-365), api_token (optional) |
rebalance_portfolio | Calculate BUY/SELL rebalancing orders to match target allocation given current user holdings. Requires an active subscription. | portfolio_code, holdings (JSON list or CSV), as_of (optional) |
get_rebalance_template | Download sample holdings CSV template and formatting instructions. | api_token (optional) |
list_blog_posts | Search and list published research articles, macro updates, and commentaries. | page, page_size, search (optional) |
get_blog_post | Read full content of a published research article by slug. | slug, api_token (optional) |
get_token_info | Inspect API token metadata, usage rate limits, and subscription status. | api_token (optional) |
Access levels
Portfolio reads serve one of two books, and every response says which via access, delayed,
as_of and lag_days:
subscribed | public_delayed | |
|---|---|---|
| Holdings | latest book | dated <= today - 45 days (PUBLIC_HOLDINGS_LAG_DAYS) |
| Position fields | ticker, weight, sector, expected return, expected volatility | ticker, weight, sector only |
equity_exposure / cash_allocation / effective_n | populated | null |
rebalance_portfolio | allowed | 403 - subscription required |
A portfolio code that is not an active public product returns 404, deliberately indistinguishable from an unknown code.
📦 Resources
| URI | Name | Description |
|---|---|---|
portfolios://catalog | Portfolio Catalog | Live catalog of all available quantitative portfolios. |
portfolios://{portfolio_code}/allocation | Portfolio Allocation | Dynamic resource for current allocation of any portfolio. |
research://posts/latest | Latest Research | Most recent quantitative market research publications. |
💡 Prompts
Ready-made starters Claude lists in the connector. Portfolio-code inputs are optional - left blank, the prompt uses the portfolios you subscribe to - and autocomplete from your live portfolio list.
| Prompt | Title | Description | Inputs |
|---|---|---|---|
my_portfolios | My portfolios at a glance | See which model portfolios you subscribe to and what each one holds right now, plus the other portfolios available on a delayed basis. | — |
access_help | My access and subscription | Explains what your account can see: live vs 45-day-delayed holdings, which portfolios you subscribe to, and what needs a subscription. | — |
portfolio_review | Review a model portfolio | In-depth look at one model portfolio: holdings and weights, sector mix, concentration, and equity vs cash. | portfolio_code (optional) |
portfolio_changes | What changed in a portfolio | Shows how a model portfolio's holdings changed over a period: positions added, removed, and the biggest weight shifts. | portfolio_code (optional), days (optional) |
compare_portfolios | Compare model portfolios | Side-by-side comparison of the model portfolios: risk level, holdings, sector mix, concentration, and overlap. | portfolio_codes (optional) |
find_holding | Which portfolios hold a stock | Look up a stock across the model portfolios: which ones hold it, at what weight, and in which sector. | ticker |
portfolio_report | Interactive portfolio report | Builds an interactive report for a model portfolio: sortable holdings, sector and concentration charts, and recent changes, as a shareable page. | portfolio_code (optional), days (optional) |
rebalance_advisor | Align my holdings to a model | Walks you through comparing your own holdings with a model portfolio and calculates the share differences. Requires a subscription to that portfolio. | portfolio_code (optional) |
market_research_digest | Research digest | Summarises the latest research articles and market commentary, optionally on one topic. | topic (optional) |
Google Cloud Run Deployment
# 1. Build and push container with Cloud Build
gcloud builds submit --config=cloudbuild.yaml --substitutions=_ENV=dev # or _ENV=prod
# 2. Deploy to Cloud Run
gcloud run deploy financial-portfolios-ai-mcp \
--image gcr.io/<YOUR_PROJECT_ID>/financial-portfolios-ai-mcp:latest \
--region us-central1 \
--platform managed \
--allow-unauthenticated \
--set-env-vars FINANCIAL_PORTFOLIOS_ENV=dev # or prod
The target is always chosen at deploy or run time. Nothing in this repository defaults to
dev or prod: without FINANCIAL_PORTFOLIOS_ENV (or an explicit FINANCIAL_PORTFOLIOS_BASE_URL)
the server refuses to start, and cloudbuild.yaml refuses to build without _ENV.
Health Endpoints
GET /- Root status, version, and endpoints metadataGET /healthz- Health and readiness checkGET /livez- Kubernetes/Cloud Run liveness probePOST /mcp- Streamable HTTP MCP endpointGET /sse- Server-Sent Events MCP endpointGET /mcp/assets/{filename}- Public brand icons (icon-16|32|48|64|128|192|256|512.png,favicon.ico)GET /mcp/manifests/{filename}- Provider manifest rendered for the requesting originGET /favicon.ico- Favicon
Branding & Icons
The server ships its logo so Claude, ChatGPT, Gemini and IDE clients render it next to the connector and its tool calls:
- In the protocol -
initializereturnsserverInfo.icons(MCPImplementation.icons, spec revision 2025-11-25). The first entry is an inline 48x48data:URI, so the icon also appears for local stdio clients with no HTTP server to fetch from; 192x192 and 512x512 follow as absolute HTTPS URLs. - Over HTTP - the PNG/ICO set is served unauthenticated from
/mcp/assets/with a one-week immutable cache header. It sits under/mcpbecause that is the prefix the portal load balancer routes to this service; top-level/assets/*belongs to the portal backend's own assets router, so an icon URL there would never reach us. The OAuth challenge explicitly exempts/mcp/assetsand/mcp/manifestsso directories can fetch them with no credential. - In the manifests -
claude_connector.jsonandchatgpt_manifest.jsonpoint theiricon_url/logo_urlat the same files, through the${PUBLIC_ORIGIN}placeholder (see Manifests).
Sources live in src/financial_portfolios_ai_mcp/assets/ and ship inside the wheel.
No environment hostname is hardcoded. The absolute URLs resolve in this order:
- the origin the request arrived on (
X-Forwarded-Proto/X-Forwarded-Host, set by the load balancer and Cloud Run) - so/always advertises the hostname the caller used; MCP_PUBLIC_BASE_URL, for theinitializehandshake, which has no request origin to read (set it when the MCP service answers on its own hostname rather than through the portal);MCP_PUBLIC_URLwith the transport path stripped.
A dev deployment therefore advertises https://dev.financial-portfolios.ai/assets/...
purely from its deploy substitution:
gcloud builds submit --config cloudbuild.yaml --substitutions=_ENV=dev
Manifests
The three provider manifests are templates, not environment-specific files: every
absolute URL in them is written as ${PUBLIC_ORIGIN}/..., so one document per provider
serves prod, dev and anything else. Nothing in the repo hardcodes a deployment hostname.
Get a submittable manifest either way:
# offline, for directory submission
python scripts/render_manifests.py --env prod # -> build/manifests/prod/
python scripts/render_manifests.py --env dev # -> build/manifests/dev/
python scripts/render_manifests.py --origin https://staging.financial-portfolios.ai
# or from a running deployment, rendered against the origin you reached it on
curl https://dev.financial-portfolios.ai/mcp/manifests/claude_connector.json
GET /mcp/manifests/<name> is the authoritative rendering: it fills in the origin the
request arrived on, so the dev deployment always hands out dev URLs and the prod
deployment prod URLs, with no build step and nothing to keep in sync. GET / lists the
available manifests. A test asserts the committed templates never regain a hardcoded
origin, and another asserts the script and the endpoint produce identical documents.
Continuous Integration
Every push and pull request runs lint, the test suite, and a smoke test against the built
image. See docs/CI.md - it needs an SDK_DEPLOY_KEY secret, because the SDK
is a separate repository.
Local Development & Testing
# 1. Install dependencies
uv sync --all-extras
# 2. Run unit tests
uv run pytest tests/ -v
# 3. Run linter
uv run ruff check .
# 4. Start local development server (Streamable HTTP & SSE on port 8080)
uv run financial-portfolios-ai-mcp http --port 8080 --reload
End-to-end smoke test
scripts/smoke_test.py exercises a running server over Streamable HTTP with the
standard library only (no deps): /healthz → initialize → tools/list, and —
if you pass an API token — real tools/call round-trips (list_portfolios →
get_portfolio_allocation). It also regression-checks that
get_portfolio_allocation advertises the words "holdings"/"positions" so that a
prompt like "show me my portfolio holdings" actually invokes it.
# Handshake + tools/list + phrasing check (no credentials needed)
python scripts/smoke_test.py
# Full path incl. entitled data (generate a token at the portal /api-access)
python scripts/smoke_test.py --token aqat_v1_xxxxx
# or: MCP_URL=http://localhost:8090/mcp/ MCP_TOKEN=aqat_v1_xxxxx python scripts/smoke_test.py
Exit code is 0 only if every executed check passes.
Local docker-compose: there is no default target. Run
FINANCIAL_PORTFOLIOS_ENV=dev docker compose up -d, or, to point the server at a local portal backend on the shared docker network, create a (gitignored).envnext todocker-compose.ymlwithFINANCIAL_PORTFOLIOS_BASE_URL=http://aqa-portal-backend:8000anddocker compose up -d.
License
MIT License. Copyright (c) 2026 Financial Portfolios AI Team.
Sourced from the repository README.
More in AI & Agents
- PonytailMakes your AI agent think like the laziest senior dev in the room. The best code is the code you never wrote.109,599
- AgentsMulti-harness agentic plugin marketplace for Claude Code, Codex, Cursor, OpenCode, GitHub Copilot, and Google Antigravity39,079
- Frontend SlidesCreate beautiful slides on the web using a coding agent's frontend skills28,060
- Agent Skills Search ServerSearch and discover Agent Skills from the skills.sh registry. Powered by HAPI MCP server.27,534
- Agency Agents Zh🎭 267 个即插即用的 AI 专家角色 — 支持 Hermes Agent/Claude Code/Cursor/Copilot 等 18 种工具,覆盖工程/设计/营销/金融等 20 个部门。含 52 个中国市场原创智能体(小红书/抖音/微信/飞书/钉钉等)。搭配编排器 agency-orchestrator,一句话即可让多位专家按 DAG 自动协作。19,868
- Watermarks RemoverStrip multi-vendor AI provenance marks: Unicode text hygiene, statistical rewrite hooks, and C2PA/metadata from PNG/JPEG/SVG/PDF/DOCX/HTML/MD17,822