Skip to main content
Glama
KSEI MCP

KSEI MCP

by nichsedge

KSEI

License: MIT

A Python client library and Model Context Protocol (MCP) server for accessing your AKSes KSEI (Acuan Kepemilikan Sekuritas Kustodian Sentral Efek Indonesia) portfolio data.

Retrieve complete Indonesian securities portfolio information:

  • ๐Ÿ’ต Cash balances (RDN)

  • ๐Ÿ“ˆ Equity holdings (Saham)

  • ๐Ÿ“Š Mutual funds (Reksadana)

  • ๐Ÿ“œ Bonds (Obligasi & SBN)

  • ๐Ÿ’ผ Other investment instruments

  • ๐Ÿ‘ค Account identity & SID


๐Ÿ”ง Prerequisites

  • Python 3.11 or higher

  • Valid KSEI account credentials

  • uv (recommended for fast package management)


Related MCP server: traderepublic-mcp

โš™๏ธ Configuration

Set your KSEI credentials via environment variables or a .env file:

export KSEI_USERNAME="your_ksei_username"
export KSEI_PASSWORD="your_ksei_password"

# Optional: Override token cache location (defaults automatically to ~/.cache/ksei)
# export KSEI_AUTH_PATH="/custom/path"

๐Ÿš€ Usage

1. As a Python Library

Tokens are automatically cached in ~/.cache/ksei with restricted 0o700/0o600 permissions.

import asyncio
from ksei import KSEIClient

# Initialize client (no auth_store boilerplate needed!)
client = KSEIClient(username="your_username", password="your_password")

# Synchronous usage
summary = client.get_portfolio_summary()
cash = client.get_cash_balances()
equities = client.get_equity_balances()
funds = client.get_mutual_fund_balances()
bonds = client.get_bond_balances()

# Asynchronous usage (fast parallel fetch)
async def main():
    async with KSEIClient(username="your_username", password="your_password") as client:
        all_portfolios = await client.get_all_portfolios_async()
        print(all_portfolios)

asyncio.run(main())

2. As an MCP Server (for AI Assistants)

Quick Run with uvx

# Run directly with uvx
uvx ksei-mcp

# Or run from local checkout
uvx --from . ksei-mcp

MCP Client Configuration

Add this configuration to your MCP client (Claude Desktop, Cursor, Gemini CLI, etc.):

{
  "mcpServers": {
    "ksei": {
      "type": "stdio",
      "command": "uvx",
      "args": ["ksei-mcp"],
      "env": {
        "KSEI_USERNAME": "your_ksei_username",
        "KSEI_PASSWORD": "your_ksei_password"
      }
    }
  }
}

3. CLI Commands

# Start MCP server
uv run ksei mcp

# Fetch and dump raw portfolio JSON
uv run ksei dump --output ./data

๐Ÿงช Testing with MCP Inspector

For local MCP debugging:

npx @modelcontextprotocol/inspector uv run ksei-mcp

๐Ÿ” Security & Privacy

  • Zero Boilerplate Cache: Tokens are cached automatically in ~/.cache/ksei (XDG standard) with user-only permissions (0o700 directory, 0o600 files).

  • Secret Protection: Passwords and tokens are never logged or exposed in __repr__ or unhandled exceptions.

  • Auto 401 Recovery: The client transparently refreshes expired tokens on 401 Unauthorized responses.

  • Secure Transport: All requests communicate with official KSEI endpoints via HTTPS.


๐Ÿ“„ License

Licensed under the MIT License. See LICENSE for details.


โš ๏ธ Disclaimer

This is an unofficial client for educational and personal use only. It is not affiliated with or endorsed by PT Kustodian Sentral Efek Indonesia (KSEI).

Acknowledgement

Adapted and inspired by chickenzord/goksei.

Available Tools

8 tools
get_all_portfoliosA

Fetch all portfolio holdings (cash, equities, mutual funds, bonds, other) in parallel.

Inputs: no named parameters. Returns: result

get_bond_balancesA

Get bond and government securities holdings (Obligasi / SBN).

Inputs: no named parameters.

get_cash_balancesA

Get detailed cash (Rekening Dana Nasabah / RDN) balances across securities accounts.

Inputs: no named parameters.

get_equity_balancesA

Get detailed Indonesian stock holdings (Saham) including shares, market value, and prices.

Inputs: no named parameters.

get_global_identityA

Get KSEI account holder identity, SID, and investor profile details.

Inputs: no named parameters.

get_mutual_fund_balancesA

Get detailed mutual fund holdings (Reksadana) including unit counts and NAV values.

Inputs: no named parameters.

get_other_balancesA

Get other financial instruments and investment balances.

Inputs: no named parameters.

get_portfolio_summaryA

Get high-level summary of all portfolio holdings and balances from AKSes KSEI.

Inputs: no named parameters.

Tool Schema Changelog

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

Loading tool schema changelogโ€ฆ

    TDQS

    A4/5.0

    Scored across 8 tools

    Disambiguation5/5

    Each tool targets a distinct aspect of the KSEI account: identity, summary, specific asset classes (cash, equity, mutual funds, bonds, other), and an aggregate fetch. No overlap between tools, and get_all_portfolios is explicitly a parallel convenience.

    Naming Consistency5/5

    All tools follow the same get_<object>_<detail> pattern with snake_case. Names are uniform and predictable, making it easy for an agent to infer function from name alone.

    Tool Count5/5

    8 tools is well-scoped for a read-only portfolio information server. Each tool covers a meaningful scope, and the count is neither too thin nor excessive.

    Completeness4/5

    The server covers all major asset classes and provides identity, summary, and full portfolio retrieval. Minor gaps like transaction history or historical performance exist, but the core read-only portfolio surface is well covered.

    Maintenance

    ActivityNo data
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      A read-only MCP server for Trade Republic that provides portfolio, cash balance, real-time quotes, and instrument search via an unofficial API.
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      A read-only MCP server that provides filtered account and portfolio data from Portfolio Performance .portfolio files to generate reports.
      10
      MIT
    • A
      license
      B
      quality
      C
      maintenance
      Unofficial MCP server for querying and managing financial data from Despezzas.
      35
      1
      MIT