Skip to content

feat: add MCP server to expose Finary portfolio to LLMs#266

Draft
nmathey wants to merge 3 commits intolasconic:mainfrom
nmathey:MCP-server
Draft

feat: add MCP server to expose Finary portfolio to LLMs#266
nmathey wants to merge 3 commits intolasconic:mainfrom
nmathey:MCP-server

Conversation

@nmathey
Copy link
Copy Markdown
Contributor

@nmathey nmathey commented Mar 12, 2026

Related to #265.

Introduces mcp_server.py, a Model Context Protocol server that wraps the existing finary_uapi functions and exposes them as MCP tools. This allows any MCP-compatible LLM client (Claude Desktop, Cursor…) to query a Finary portfolio in natural language.

18 read-only tools covering investments, cryptos, real estates, crowdlendings, precious metals, SCPIs, fonds euro, startups and generic assets
Session handled via the existing auth.prepare_session() and credentials.json — no extra auth setup required
Requires mcp >= 1.0.0 added to pyproject.toml
Updated README with setup instructions and usage examples

@lasconic
Copy link
Copy Markdown
Owner

I tested a couple calls and they don't work. get_portfolio doesn't work for generic_assets or scpis. The mapping needs to be changed and tested one by one.

For reference, I used the following file with LMstudio and Qwen3.5-9b (so everything running locally)

{
  "mcpServers": {
    "finary": {
      "command": "poetry",
      "args": [
        "-C",
        "{FINARY_UAPI_FULL_PATH}",
        "run",
        "python",
        "mcp_server.py"
      ]
    }
  }
}

@nmathey nmathey marked this pull request as draft March 15, 2026 23:24
@nmathey
Copy link
Copy Markdown
Contributor Author

nmathey commented Mar 16, 2026

Working mapping:

Catégorie Fonction associée
Immobilier physique user_real_estates.get_user_real_estates
SCPI user_scpis.get_user_scpis
Fonds euros user_fonds_euro.get_user_fonds_euro
Startups & PME user_startups.get_user_startups
Métaux précieux user_precious_metals.get_user_precious_metals
Crowdlending user_crowdlendings.get_user_crowdlendings
Actifs génériques user_generic_assets.get_user_generic_assets

Introduces a new tool to aggregate and return total wealth values
by asset category, providing a consolidated view across real estate,
SCPI, investments, crypto, and other asset types. Refactors data
retrieval to use more granular category-specific APIs for improved
accuracy and clarity. Enhances error handling and data extraction
for summary calculations.
@nmathey
Copy link
Copy Markdown
Contributor Author

nmathey commented Mar 16, 2026

I did fix some function calls but I'll need to install LMstudio and Qwen3.5-9b like you in order to test again as I'm getting size response limite form my free claude desktop account...

@lasconic
Copy link
Copy Markdown
Owner

It's a hint that the finary API is too verbose as it maybe ? The server could reduce the verbosity to limit the token usage ?

@nmathey
Copy link
Copy Markdown
Contributor Author

nmathey commented Mar 17, 2026

Ok I did refactor responses handling to optimize token usage.
Looks good on my side now if you can try again on yours @lasconic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants