Introduction
In this tutorial, we build an advanced workflow around Anthropic’s financial-services repository and reproduce its skill-driven architecture using pure Python. Designed for analysts, developers, and AI engineers in 2026, this guide demonstrates how to construct modular, reusable financial agents that integrate Claude’s language capabilities with Python-based computation and automated document generation.
Prerequisites and Setup
Begin by installing the required libraries and cloning the repository. The key components include:
- Anthropic’s financial-services repository – Contains skill definitions, agent blueprints, and financial analysis playbooks.
- Python 3.11+ – Core execution environment.
- Claude API (via Anthropic Messages API) – Powers natural language understanding and structured reasoning.
- MCP Connectors – Enable modular integration of external data sources and computation tools.
Step 1: Install Dependencies
pip install anthropic pandas openpyxl matplotlib numpy requests
Step 2: Clone the Repository
git clone https://github.com/anthropic/financial-services.git
cd financial-services
Mapping the Architecture
We programmatically inspect the repository to identify:
- Agents – Self-contained assistants with specific roles (e.g., valuation, risk, reporting).
- Vertical plugins – Domain-specific extensions (e.g., real estate, private equity).
- Partner integrations – Pre-built connectors for platforms like Bloomberg, FactSet, and MCP-compatible services.
- Managed-agent cookbooks – Recipes for deploying agents in production environments.
- Financial analysis skills – Modular playbooks defining tasks like DCF modeling or sensitivity analysis.
Parsing Skill Definitions
Each skill is defined in a SKILL.md file. We parse these into a searchable registry using Python:
import os
import glob
skills_registry = {}
skill_files = glob.glob("**/SKILL.md", recursive=True)
for file in skill_files:
with open(file, 'r') as f:
content = f.read()
# Extract metadata (you can customize parsing)
skill_name = os.path.basename(os.path.dirname(file))
skills_registry[skill_name] = content
print(f"Registered {len(skills_registry)} skills.")
Building a Reusable SkillAgent
We construct a SkillAgent class that:
- Loads a selected financial playbook (skill).
- Injects it into the Anthropic Messages API context.
- Supports an iterative tool-use loop for Python calculations and file generation.
- Extend the skill registry with custom financial models.
- Deploy agents using Docker and Kubernetes for scalability.
- Integrate with MCP-compatible market data providers for live analysis.
Core Class Structure
from anthropic import Anthropic
import json
class SkillAgent:
def __init__(self, api_key, skill_content, model="claude-3-5-sonnet-20241022"):
self.client = Anthropic(api_key=api_key)
self.skill = skill_content
self.model = model
self.conversation_history = []
def add_system_prompt(self):
return f"You are a financial analysis agent. Follow this skill playbook:\n\n{self.skill}"
def execute_task(self, user_query, tools=None):
messages = self.conversation_history + [{"role": "user", "content": user_query}]
response = self.client.messages.create(
model=self.model,
system=self.add_system_prompt(),
messages=messages,
tools=tools or []
)
self.conversation_history.append({"role": "assistant", "content": response.content})
return response
Integrating MCP Connectors
MCP (Model Context Protocol) connectors allow the agent to pull live data (e.g., stock prices, exchange rates) or push results to external systems. Example connector structure:
class MCPConnector:
def __init__(self, endpoint, api_key):
self.endpoint = endpoint
self.api_key = api_key
def fetch_data(self, query):
# Implement data retrieval logic
pass
def send_report(self, data):
# Implement output delivery
pass
Practical Financial Analysis Workflows
1. Synthetic Discounted Cash Flow (DCF) Valuation
Using the cloned skill playbook, the agent performs a full DCF calculation:
agent = SkillAgent(api_key="your-key", skill_content=skills_registry["dcf_valuation"])
response = agent.execute_task("Run a DCF valuation for a fictional company with $100M free cash flow, 10% WACC, and 3% terminal growth.")
The agent returns step-by-step cash flow projections and a fair value estimate.
2. WACC and Terminal-Growth Sensitivity Heatmap
We extend the agent to generate a sensitivity matrix and visualize it:
import numpy as np
import matplotlib.pyplot as plt
wacc_range = np.linspace(0.08, 0.12, 5)
growth_range = np.linspace(0.02, 0.05, 5)
sensitivity = np.zeros((5, 5))
for i, w in enumerate(wacc_range):
for j, g in enumerate(growth_range):
sensitivity[i, j] = 100 / (w - g) # Simplified perpetuity formula
plt.imshow(sensitivity, cmap="viridis", aspect="auto")
plt.colorbar(label="Enterprise Value ($M)")
plt.title("WACC vs Terminal Growth Sensitivity")
plt.xlabel("Terminal Growth")
plt.ylabel("WACC")
plt.savefig("sensitivity_heatmap.png")
3. Comparable Company Analysis with Excel Output
The agent queries a peer set, computes multiples, and exports to formatted Excel:
# Sample data
comps = {
"Company": ["Peer A", "Peer B", "Peer C"],
"EV/EBITDA": [12.5, 14.2, 11.8],
"P/E": [22.1, 25.4, 20.3]
}
import pandas as pd
df = pd.DataFrame(comps)
df.to_excel("comparable_analysis.xlsx", index=False, sheet_name="Comps")
4. Private-Equity Investment Committee Memo
Using a managed-agent cookbook, the agent drafts a full memo with executive summary, financial analysis, risk factors, and recommendation:
memo_prompt = """
Draft an investment committee memo for a potential $200M acquisition of a SaaS company.
Include valuation rationale, exit scenarios, and key risks.
"""
response = agent.execute_task(memo_prompt)
with open("investment_memo.docx", "w") as f:
f.write(response.content[0].text)
5. Inspecting a Managed-Agent Deployment Specification
We programmatically examine deployment configs without triggering real actions:
deployment_spec = {
"agent_name": "PE_Analyst",
"skills": ["dcf", "lbo", "comps"],
"schedule": "daily",
"output_targets": ["slack", "sharepoint"]
}
print("Dry-run inspection:", json.dumps(deployment_spec, indent=2))
Conclusion
By combining Claude’s reasoning, Python’s computational power, MCP connectors for real-time data, and a skill-driven architecture, you can deploy financial analysis agents that are both modular and production-ready. This approach is especially relevant in 2026 as AI agents become central to automated financial workflows, from deal sourcing to reporting. The full code and repository integration allow you to adapt these patterns to your own use cases—whether for private equity, corporate finance, or asset management.
Next Steps
via MarkTechPost
