MCP server dla myFund.pl — narzędzia portfela inwestycyjnego dla Claude
myFund.pl MCP Server
Spis treści
- Narzędzia
- Przykłady użycia
- Wymagania
- Instalacja
- Rozwiązywanie problemów
- Zmienne środowiskowe
- Uwagi techniczne
- Licencja
Serwer MCP (Model Context Protocol) udostępniający dane portfela inwestycyjnego z myFund.pl jako narzędzia dla Claude Desktop.
Narzędzia
| Narzędzie | Co zwraca |
|---|---|
| get_portfolio | Podsumowanie portfela: wartość, zysk, stopy zwrotu za okresy (1T / 1M / 3M / 1R / 5R…) |
| get_positions | Lista pozycji posortowana wg wartości (ticker, typ, sektor, konto, zysk) |
| get_allocation | Alokacja wg typu aktywów i wg walorów z kolorami |
| get_portfolio_timeseries | Szereg czasowy: wartość / zysk / wkład / benchmark / stopa zwrotu |
Przykłady użycia
Po podpięciu serwera możesz zadawać Claude pytania w naturalnym języku:
Podsumowanie i wyniki:
„Pokaż podsumowanie portfela Inwestycje" „Jaki jest mój całkowity zysk i stopa zwrotu od początku roku?" „Jak zmieniała się wartość portfela przez ostatnie 12 miesięcy?"
Pozycje i selekcja:
„Które 5 pozycji przyniosło największy zysk?" „Pokaż wszystkie pozycje na koncie IKE" „Jakie ETF-y mam w portfelu i ile każdy z nich waży?"
Alokacja:
„Jak wygląda podział portfela wg typu aktywów?" „Które walory mają największy udział w portfelu?" „Czy jestem zdywersyfikowany sektorowo?"
Analiza w czasie:
„Porównaj stopę zwrotu portfela z benchmarkiem WIG w tym roku" „Kiedy portfel osiągnął najwyższą wartość?" „Pokaż dzienny zysk/stratę za ostatni miesiąc"
Wymagania
- macOS, Windows lub Linux
- Python 3.10 lub nowszy
- Claude Desktop
Instalacja
1. Pobierz skrypt
Pobierz plik myfund_mcp_server.py i przenieś go do wybranego folderu, np.:
mkdir -p ~/mcp-servers
mv ~/Downloads/myfund_mcp_server.py ~/mcp-servers/
2. Zainstaluj Pythona 3.12 (jeśli nie masz)
macOS:
brew install python@3.12
Windows: pobierz instalator z python.org.
3. Utwórz środowisko wirtualne i zainstaluj zależności
macOS / Linux:
/opt/homebrew/bin/python3.12 -m venv ~/mcp-servers/venv
~/mcp-servers/venv/bin/python -m pip install "mcp" httpx
Windows:
python -m venv %USERPROFILE%\mcp-servers\venv
%USERPROFILE%\mcp-servers\venv\Scripts\python -m pip install "mcp" httpx
4. Pobierz klucz API z myFund.pl
Zaloguj się → Menu → Konto → Ustawienia konta → Klucz API → wygeneruj i skopiuj.
⚠️ Wygenerowanie nowego klucza natychmiast unieważnia poprzedni.
5. Skonfiguruj Claude Desktop
Otwórz: Settings → Developer → Edit Config
Lokalizacja pliku konfiguracyjnego:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json
Wklej do sekcji "mcpServers":
{
"mcpServers": {
"myfund": {
"command": "/Users/TWOJA_NAZWA/mcp-servers/venv/bin/python",
"args": ["/Users/TWOJA_NAZWA/mcp-servers/myfund_mcp_server.py"],
"env": {
"MYFUND_API_KEY": "TWOJ_KLUCZ_API"
}
}
}
}
Podmień:
TWOJA_NAZWA→ nazwa użytkownika systemowego (na macOS: wynikwhoamiw Terminalu)TWOJ_KLUCZ_API→ klucz z kroku 4
Ważne:
commandmusi wskazywać na Pythona z venv — tego, do którego zainstalowanomcp.
6. Zrestartuj Claude Desktop
Cmd+Q (macOS) lub całkowite zamknięcie, potem uruchom ponownie.
7. Test
W nowym czacie napisz:
Pokaż podsumowanie portfela „Nazwa Twojego Portfela"
Rozwiązywanie problemów
❌ No module named 'mcp'
Przyczyna: Claude uruchamia Pythona systemowego zamiast tego z venv.
Rozwiązanie: Upewnij się, że command w configu wskazuje na ~/mcp-servers/venv/bin/python, a nie na systemowy python3.
❌ Odpowiedź nie jest poprawnym JSON-em
Przyczyna: Niepoprawny klucz API lub brak dostępu do bety myFund.pl. Rozwiązanie: Sprawdź klucz w Menu → Konto → Ustawienia konta → Klucz API. Jeśli klucz jest świeży a błąd pozostaje — API myFund.pl jest w fazie beta i dostęp może być ograniczony do wybranych kont.
❌ Portfel nie znaleziony (status 7)
Przyczyna: Nazwa portfela nie zgadza się dokładnie z nazwą na koncie. Rozwiązanie: Sprawdź dokładną nazwę portfela na myFund.pl (wielkość liter, spacje). Nazwa musi być identyczna co do znaku.
❌ Narzędzia nie pojawiają się w Claude Desktop
Przyczyna: Błąd przy starcie serwera lub niepoprawna składnia JSON w configu. Rozwiązanie: Wejdź w Settings → Developer — tam widoczny jest status każdego serwera i log błędów. Najczęściej: literówka w ścieżce lub brakujący przecinek w JSON.
❌ Dane są nieaktualne
Przyczyna: API myFund.pl cache'uje odpowiedzi przez 5 minut. Rozwiązanie: Odczekaj 5 minut od ostatniej zmiany w portfelu i zapytaj ponownie.
Zmienne środowiskowe
| Zmienna | Wymagana | Opis |
|---|---|---|
| MYFUND_API_KEY | ✅ tak | Klucz API z ustawień konta myFund.pl |
| MYFUND_BASE_URL | ❌ nie | Nadpisuje base URL (domyślnie https://myfund.pl/API/v1) |
Uwagi techniczne
- API myFund.pl jest w fazie beta — dostęp może być ograniczony do wybranych kont
- Odpowiedzi cache'owane 5 minut po stronie serwera
- Wiele wartości zwracanych jako stringi z prefiksem
+— serwer parsuje defensywnie - Błędy logiczne sygnalizowane w
status.codemimo HTTP 200 ("0"= sukces,"1"= błąd,"7"= portfel nie znaleziony)
Licencja
MIT
🇬🇧 English version
Table of contents
- Tools
- Usage examples
- Requirements
- Installation
- Troubleshooting
- Environment variables
- Technical notes
- License
An MCP (Model Context Protocol) server that exposes your myFund.pl investment portfolio data as tools for Claude Desktop.
Tools
| Tool | Returns |
|---|---|
| get_portfolio | Portfolio summary: value, profit, returns for periods (1W / 1M / 3M / 1Y / 5Y…) |
| get_positions | List of holdings sorted by value (ticker, type, sector, account, profit) |
| get_allocation | Allocation by asset type and by security, with hex colours |
| get_portfolio_timeseries | Time series: value / profit / contribution / benchmark / return |
Usage examples
Once connected, you can ask Claude questions in plain language:
Summary & performance:
"Show me a summary of my Investments portfolio" "What is my total profit and year-to-date return?" "How has my portfolio value changed over the last 12 months?"
Holdings & selection:
"Which 5 positions have generated the most profit?" "Show all positions held in my IKE account" "What ETFs do I hold and what is each one's weight in the portfolio?"
Allocation:
"How is my portfolio split by asset type?" "Which securities have the largest share of the portfolio?" "Am I well diversified across sectors?"
Time series analysis:
"Compare my portfolio return against the WIG benchmark this year" "When did my portfolio reach its peak value?" "Show daily profit/loss for the last month"
Requirements
- macOS, Windows or Linux
- Python 3.10 or newer
- Claude Desktop
Installation
1. Download the script
Download myfund_mcp_server.py and move it to a permanent location, e.g.:
mkdir -p ~/mcp-servers
mv ~/Downloads/myfund_mcp_server.py ~/mcp-servers/
2. Install Python 3.12 (if you don't have it)
macOS:
brew install python@3.12
Windows: download the installer from python.org.
3. Create a virtual environment and install dependencies
macOS / Linux:
/opt/homebrew/bin/python3.12 -m venv ~/mcp-servers/venv
~/mcp-servers/venv/bin/python -m pip install "mcp" httpx
Windows:
python -m venv %USERPROFILE%\mcp-servers\venv
%USERPROFILE%\mcp-servers\venv\Scripts\python -m pip install "mcp" httpx
4. Get your API key from myFund.pl
Log in → Menu → Account → Account Settings → API Key → generate and copy.
⚠️ Generating a new key immediately invalidates the previous one.
5. Configure Claude Desktop
Open: Settings → Developer → Edit Config
Config file location:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json
Add the following block inside "mcpServers":
{
"mcpServers": {
"myfund": {
"command": "/Users/YOUR_USERNAME/mcp-servers/venv/bin/python",
"args": ["/Users/YOUR_USERNAME/mcp-servers/myfund_mcp_server.py"],
"env": {
"MYFUND_API_KEY": "YOUR_API_KEY"
}
}
}
}
Replace:
YOUR_USERNAME→ your system username (on macOS: runwhoamiin Terminal)YOUR_API_KEY→ the key from step 4
Important:
commandmust point to the Python binary inside the venv — the one wheremcpwas installed.
6. Restart Claude Desktop
Cmd+Q (macOS) or fully close the app, then relaunch.
7. Test
In a new chat, type:
Show me a summary of my portfolio "Your Portfolio Name"
Troubleshooting
❌ No module named 'mcp'
Cause: Claude is launching the system Python instead of the venv one.
Fix: Make sure command in the config points to ~/mcp-servers/venv/bin/python, not the system python3.
❌ Response is not valid JSON
Cause: Invalid API key or no access to the myFund.pl beta. Fix: Check your key at Menu → Account → Account Settings → API Key. If the key is fresh and the error persists, the myFund.pl API is in beta and access may be restricted to selected accounts.
❌ Portfolio not found (status 7)
Cause: Portfolio name doesn't exactly match the name on your account. Fix: Check the exact portfolio name on myFund.pl (case-sensitive, watch for trailing spaces). The name must match character for character.
❌ Tools don't appear in Claude Desktop
Cause: Server failed to start, or invalid JSON syntax in the config file. Fix: Go to Settings → Developer — each server's status and error log is shown there. Most common causes: typo in a file path, or a missing comma in the JSON.
❌ Data appears stale
Cause: myFund.pl API caches responses for 5 minutes. Fix: Wait 5 minutes after making changes to your portfolio, then ask again.
Environment variables
| Variable | Required | Description |
|---|---|---|
| MYFUND_API_KEY | ✅ yes | API key from myFund.pl account settings |
| MYFUND_BASE_URL | ❌ no | Overrides base URL (default: https://myfund.pl/API/v1) |
Technical notes
- myFund.pl API is in beta — access may be limited to selected accounts
- Responses are cached for 5 minutes server-side
- Many values are returned as strings with a
+prefix — the server parses them defensively - Logical errors are signalled in
status.codedespite HTTP 200 ("0"= success,"1"= error,"7"= portfolio not found)
License
MIT