Skip to main content
Glama
kimagure-dd

@kimagure-dd/xirr-mcp

by kimagure-dd

@kimagure-dd/xirr-mcp

npm version License: MIT

**XIRR(拡張内部収益率)**を計算するためのMCPサーバーです。楽天証券の取引履歴CSVの読み込みを標準サポートしています。

Claude DesktopやClaude Codeに組み込み、証券会社からエクスポートしたCSVを渡して以下のように質問してください:

「この CSV と現在の評価額 ¥1,500,000 で、実績年利を計算して」

Claudeが不定期な入出金を考慮してXIRRを計算し、結果を解説します。

機能

  • 🧮 calculate_xirr — 任意のキャッシュフローと現在の評価額からXIRRを計算

  • 📄 parse_rakuten_csv — 楽天証券の取引履歴CSVを正規化されたキャッシュフローに変換

  • 🔌 ネットワークアクセス不要の純粋なstdio MCPサーバー

  • 📦 ランタイム設定不要、npxコマンド一つで実行可能

Related MCP server: ibkr-mcp

インストールとセットアップ

Claude Desktop

~/Library/Application Support/Claude/claude_desktop_config.json (macOS) または %APPDATA%\Claude\claude_desktop_config.json (Windows) を編集します:

{
  "mcpServers": {
    "xirr": {
      "command": "npx",
      "args": ["-y", "@kimagure-dd/xirr-mcp"]
    }
  }
}

Claude Desktopを再起動してください。calculate_xirr および parse_rakuten_csv ツールが表示されるはずです。

Claude Code

claude mcp add xirr -- npx -y @kimagure-dd/xirr-mcp

使用例

直接計算

Claudeに以下のように尋ねます:

「以下のキャッシュフローで XIRR を計算して。2020-01-01 に 100万円投資、2022-01-01 に 50万円追加、現在(2025-01-01)の評価額 200万円」

Claudeは構造化された入力で calculate_xirr を呼び出し、以下を返します:

{
  "annualRate": 12.34,
  "annualRateFormatted": "12.34%",
  "totalInvestment": 1500000,
  "totalGain": 500000,
  "gainRateFormatted": "33.33%",
  "converged": true
}

楽天証券のCSVから計算

  1. 楽天証券にログイン → 取引履歴 → CSV ダウンロード

  2. (Shift_JIS でダウンロードされるため UTF-8 に変換してください)

  3. Claude にファイル内容を渡して「これで実績年利を計算して。現在の評価額は ¥X」と依頼

Claudeは自動的にCSVを parse_rakuten_csv → calculate_xirr の順で処理します。

ツールリファレンス

calculate_xirr

日付付きキャッシュフローのリストと現在の評価額からXIRRを計算します。

入力:

フィールド

型

説明

cashFlows

array

{ date, amount } のリスト。正の値=投資、負の値=引き出し。

currentValue

number

現在のポートフォリオ評価額。

valuationDate

string

YYYY-MM-DD。currentValue の日付。

出力:

フィールド

型

説明

annualRate

number

年率換算された収益率(パーセント)。

monthlyRate

number

月率(年率に複利換算)。

totalInvestment

number

全キャッシュフローの合計。

totalGain

number

currentValue - totalInvestment。

gainRate

number

投資額に対する合計利益率(パーセント)。

converged

boolean

反復計算が収束した場合は true。

parse_rakuten_csv

楽天証券の取引履歴CSVを解析します。

入力:

フィールド

型

説明

csvContent

string

生のCSVテキスト(UTF-8デコード済み)。

必要なCSVヘッダー:

約定日, 取引, ファンド名, 受渡金額/(ポイント利用)[円]

動作:

  • 買付 行 → 正の金額(投資)

  • その他の取引タイプ(例: 売却) → 負の金額(引き出し)

  • 無効な行は警告とともにスキップされます

計算方法

  • メインソルバーとしてニュートン・ラフソン法を使用

  • ニュートン法で収束しない場合は二分法にフォールバック

  • 時間単位: 月(1ヶ月あたり 365.25 / 12 日を使用)

  • 収束閾値: 1e-7

kimagure-dd.devのブラウザ版XIRR計算機 と同じロジックを使用しているため、結果は同一です。

免責事項

本ツールは情報提供のみを目的として投資パフォーマンスを計算します。 税金、取引手数料、為替換算は考慮されていません。 出力は投資助言を構成するものではありません。

開発

npm install
npm run build
npm test

公開前にローカルでサーバーをテストするには:

npm pack
# Then point Claude Desktop to the .tgz path

ライセンス

MIT © kimagure-dd

関連

Available Tools

2 tools
calculate_xirrA

Calculate XIRR (Extended Internal Rate of Return) from a series of dated cash flows and a current portfolio valuation. Returns annualized rate, monthly rate, total gain, and convergence status. Useful for measuring actual investment performance accounting for irregular contributions and withdrawals.

ParametersJSON Schema
NameRequiredDescriptionDefault
cashFlowsYesList of cash flows. Use positive amounts for investments (buy), negative for withdrawals (sell).
currentValueYesCurrent valuation of the portfolio at valuationDate.
valuationDateYesDate of the current valuation in YYYY-MM-DD format.

TDQS

A4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description must disclose behavioral traits. It indicates the outputs (annualized rate, monthly rate, total gain, convergence status) but does not mention potential issues like convergence failures, input validation, or performance limitations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two sentences long, front-loaded with the purpose and return values. Every word is informative and there is no redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of output schema, the description adequately lists the return values (annualized rate, monthly rate, total gain, convergence status). It covers the essential outputs for a financial calculation tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% coverage, so the description adds limited semantic value beyond what's already documented. It reiterates that positive amounts are investments, which is already in the schema, but does not provide new details.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action 'Calculate XIRR' and the resource 'from a series of dated cash flows and a current portfolio valuation'. It distinguishes this tool from its sibling parse_rakuten_csv, which handles CSV parsing, by focusing on financial computation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explains when to use the tool ('useful for measuring actual investment performance...'), but does not explicitly mention when not to use it or provide alternatives. However, given the distinct sibling tool, no confusion arises.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

parse_rakuten_csvA

Parse a Rakuten Securities transaction CSV (取引履歴) and convert it into a normalized cash flow list. Handles 買付/売却 transaction types automatically. The output can be fed directly into calculate_xirr.

ParametersJSON Schema
NameRequiredDescriptionDefault
csvContentYesRaw CSV text exported from Rakuten Securities. Note: Rakuten exports are typically Shift_JIS encoded; decode to UTF-8 before passing.

TDQS

A4.2/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It discloses the automatic handling of transaction types and encoding issues, but lacks details on error behavior, file size limits, or other edge cases. It is partially transparent but leaves gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two sentences that are efficiently front-loaded. The first sentence states the core purpose, the second adds key details. Every sentence is meaningful with no superfluous words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the simple tool (1 param, no output schema), the description covers input format, handling, and integration with calculate_xirr. It could mention the output structure more explicitly, but it is sufficient for an agent to understand usage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema has 100% coverage with a single parameter. The description adds value by explaining the parameter is raw CSV text and specifically notes the Shift_JIS encoding issue, which is critical for correct usage. This exceeds the baseline of 3 for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool parses Rakuten Securities transaction CSV and converts to normalized cash flow list, handling specific transaction types. It implicitly distinguishes from the sibling tool calculate_xirr by indicating the output feeds into it.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description says when to use the tool (when you have a Rakuten Securities CSV) and hints at the workflow with calculate_xirr. It provides encoding context but doesn't explicitly state when not to use it or list alternatives, though the sibling count is low.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 2 tool updatesv0.1.0
    • First observedcalculate_xirr
    • First observedparse_rakuten_csv

TDQS

A4.3/5.0

Scored across 2 tools

Disambiguation5/5

The two tools have clearly distinct purposes: parse_rakuten_csv converts a specific CSV into cash flows, and calculate_xirr performs the actual rate calculation. No overlap exists.

Naming Consistency5/5

Both tools follow a consistent verb_noun pattern using snake_case: parse_rakuten_csv and calculate_xirr. Perfectly consistent.

Tool Count4/5

With only 2 tools, the server is very focused but appropriately scoped for the specific use case of Rakuten CSV processing and XIRR calculation. A slightly broader tool count could be argued, but it's reasonable.

Completeness5/5

For the domain of computing XIRR from Rakuten CSV data, the server is complete. The parse-then-calculate workflow covers all necessary steps without missing functionality.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

  • MCP server for VC pitch-deck scoring, thesis-fit matching, and deal-flow management.

  • Research-only MCP server: your AI as a quant research desk. 90 tools, no trades, no brokers.

  • Research US-listed companies and funds with the StockPortfolio.pro MCP server. Tools cover SEC filing-grounded financials, filing timelines, company comparisons, watchlist screens, fund profiles, and cited filing questions. Filed figures include their fiscal period and EDGAR source URL; missing filing data is returned as null. Public tools work without authentication; optional API-key or OAuth access is supported. US-listed, USD-reporting companies only. Keyless access includes 3 free AI questions per rolling 30-day window. To get more now, choose the Dev plan ($19.99/month, 200 credits) at https://www.stockportfolio.pro/register?plan=dev, then follow https://www.stockportfolio.pro/docs/api-mcp to connect with OAuth or an API key. Or wait for the free allowance to renew.

  • MCP server exposing the Backtest360 engine API as tools for AI agents.

Related MCP Servers

  • A
    license
    A
    quality
    C
    maintenance
    A portfolio analysis MCP server that enables AI agents to manage investment portfolios, fetch financial data from Yahoo Finance and CoinGecko, and perform advanced analysis like weight optimization and Monte Carlo simulations. It utilizes reference-based caching to efficiently handle large datasets without bloating the LLM's context window.
    26
    1
    MIT
  • F
    license
    Not graded
    quality
    B
    maintenance
    An MCP server that turns Interactive Brokers into a question-answering portfolio analyst.
    4
    -
  • A
    license
    A
    quality
    C
    maintenance
    An MCP server that enables querying Easy Equities and Satrix investment accounts, including holdings, valuations, and transactions, via natural language.
    9
    1
    MIT
  • F
    license
    A
    quality
    B
    maintenance
    MCP server providing portfolio analytics tools: beta to a benchmark, sector correlation, and FIFO trade matching with realized/unrealized P&L using Yahoo Finance prices.
    3
    -