@kimagure-dd/xirr-mcp
MCP server for calculating XIRR (Extended Internal Rate of Return) from cash flows and Rakuten Securities CSV, enabling natural language portfolio performance queries.
README
@kimagure-dd/xirr-mcp
MCP server for XIRR (Extended Internal Rate of Return) calculation, with built-in support for Rakuten Securities (楽天証券) transaction CSV.
Plug it into Claude Desktop or Claude Code, hand it a CSV exported from your brokerage, and ask:
「この CSV と現在の評価額 ¥1,500,000 で、実績年利を計算して」
Claude will compute the XIRR for you — accounting for irregular contributions and withdrawals — and explain the result.
Features
- 🧮
calculate_xirr— XIRR from arbitrary cash flow series + current valuation - 📄
parse_rakuten_csv— Parse Rakuten Securities transaction CSV (取引履歴) into normalized cash flows - 🔌 Pure stdio MCP server, no network access required
- 📦 Zero runtime config, single
npxcommand
Installation & Setup
Claude Desktop
Edit ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):
{
"mcpServers": {
"xirr": {
"command": "npx",
"args": ["-y", "@kimagure-dd/xirr-mcp"]
}
}
}
Restart Claude Desktop. The calculate_xirr and parse_rakuten_csv tools should appear.
Claude Code
claude mcp add xirr -- npx -y @kimagure-dd/xirr-mcp
Usage Examples
Direct calculation
Ask Claude:
「以下のキャッシュフローで XIRR を計算して。2020-01-01 に 100万円投資、2022-01-01 に 50万円追加、現在(2025-01-01)の評価額 200万円」
Claude will call calculate_xirr with structured input and return:
{
"annualRate": 12.34,
"annualRateFormatted": "12.34%",
"totalInvestment": 1500000,
"totalGain": 500000,
"gainRateFormatted": "33.33%",
"converged": true
}
From Rakuten Securities CSV
- 楽天証券にログイン → 取引履歴 → CSV ダウンロード
- (Shift_JIS でダウンロードされるため UTF-8 に変換)
- Claude にファイル内容を渡して「これで実績年利を計算して。現在の評価額は ¥X」と依頼
Claude will pipe the CSV through parse_rakuten_csv → calculate_xirr automatically.
Tool Reference
calculate_xirr
Calculates XIRR from a list of dated cash flows and a current valuation.
Input:
| Field | Type | Description |
|---|---|---|
cashFlows |
array | List of { date, amount }. Positive = invested, negative = withdrawn. |
currentValue |
number | Current portfolio valuation. |
valuationDate |
string | YYYY-MM-DD. Date of currentValue. |
Output:
| Field | Type | Description |
|---|---|---|
annualRate |
number | Annualized return as a percentage. |
monthlyRate |
number | Monthly rate (compounded to annual). |
totalInvestment |
number | Sum of all cash flows. |
totalGain |
number | currentValue - totalInvestment. |
gainRate |
number | Total gain as a percentage of investment. |
converged |
boolean | True if the iterative solver converged. |
parse_rakuten_csv
Parses a Rakuten Securities transaction CSV.
Input:
| Field | Type | Description |
|---|---|---|
csvContent |
string | Raw CSV text (UTF-8 decoded). |
Required CSV headers:
約定日, 取引, ファンド名, 受渡金額/(ポイント利用)[円]
Behavior:
買付rows → positive amount (investment)- Other transaction types (e.g.
売却) → negative amount (withdrawal) - Invalid rows are skipped with warnings
Calculation Method
- Newton-Raphson iteration as the primary solver
- Bisection fallback when Newton fails to converge
- Time unit: months (using 365.25 / 12 days per month)
- Convergence threshold: 1e-7
The same logic is used in the browser-based XIRR calculator on kimagure-dd.dev, so results are identical.
Disclaimer
This tool computes investment performance for informational purposes only. Taxes, transaction fees, and currency conversion are not considered. The output does not constitute investment advice.
Development
npm install
npm run build
npm test
To test the server locally before publishing:
npm pack
# Then point Claude Desktop to the .tgz path
License
MIT © kimagure-dd
Related
- 🌐 kimagure-dd.dev — Browser-based financial calculators
- 📊 XIRR Calculator (web version)
- 🐙 Source code
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。