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.5.0.tar.gz (130.1 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.5.0-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ksei-0.5.0.tar.gz
  • Upload date:
  • Size: 130.1 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.5.0.tar.gz
Algorithm Hash digest
SHA256 af67758a2a05161d802a3dd50d32134d2410a641fbd67f044a4cf2eaee7f0fd2
MD5 1b4438036476ba1ce616fab5bc60d9f7
BLAKE2b-256 fd89e13056bc4d25a28ce0e6c1a9679133736b1cefbff26edb8a7de0b058d81d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ksei-0.5.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.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4f45b6ca10d6f163179a74d53d761f9c2fa74dd0d49f137364fd965c04ce5d2c
MD5 da0a907947a29aca78b09c53935b1ec2
BLAKE2b-256 dd124f6cdd6e4fe12551023b599da16c17b4b8fb84d260f889c0d2d1f6a71124

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 files

0.4.0

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