Skip to main content

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)

⚙️ 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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ksei-0.4.0.tar.gz (129.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ksei-0.4.0-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file ksei-0.4.0.tar.gz.

File metadata

  • Download URL: ksei-0.4.0.tar.gz
  • Upload date:
  • Size: 129.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"44","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for ksei-0.4.0.tar.gz
Algorithm Hash digest
SHA256 c963a48105392a0f974011ffd12924bdf5e7da4fcc368f5fcffd06481737ffad
MD5 7dd5990c816b8554edd393a1b1f638de
BLAKE2b-256 0c650e28decf8694ec5ecbbd97273bed0e97e16d51d824ec3118260123f59292

See more details on using hashes here.

File details

Details for the file ksei-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: ksei-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 11.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"44","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for ksei-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 63889432f6f5577587e6940146708fa46330eeb001df2b68e35b6f02bdc24970
MD5 6e8fdf4330d581543477dca780840eb4
BLAKE2b-256 f9428b00ca854e4d8803ea561dcc03eac5a8b2fe3213a686d2f4cce9bb898452

See more details on using hashes here.

Release history Release notifications | RSS feed

0.5.0

2 files

This release

0.4.0 This release

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page