Skip to main content Switch to mobile version sahmk-mcp 0.13.0 Official SAHMK MCP server for Saudi market data in AI agents.
pip install sahmk-mcp==0.13.0 Copy PIP instructions
Official distribution: GitHub (sahmk-sa/sahmk-mcp) and PyPI (sahmk-mcp) only. Do not install from third-party forks.
Official SAHMK MCP server for SAHMK — use Saudi market data inside AI agents such as Cursor and Claude Desktop.
This MCP exposes a curated set of Sahmk tools for AI agents, so assistants can query the Saudi market in natural language.
Identifier-First Contract
Canonical inputs for quote tools are identifier and identifiers.
Legacy aliases symbol and symbols are still accepted for compatibility.
Prefer canonical keys in prompts, tool calls, and client templates.
Resolution is backend/SDK-backed (names, aliases, and symbols); MCP does not maintain its own symbol map.
When to Use MCP vs SDK
Use MCP for interactive agent workflows in tools like Cursor and Claude Desktop.
Use the Python SDK for scripts, automation, dashboards, alerts, backtests, and application code.
SDK repo: sahmk-sa/sahmk-python
Sign up at sahmk.sa/developers
Go to Dashboard → API Keys → Create Key
Copy your key (starts with shmk_live_ or shmk_test_)
get_depth is entitlement-gated. Request realtime/depth access from the developer dashboard:
Request realtime access
Required Environment Variables
SAHMK_API_KEY is required for all server runs (Claude Desktop, Cursor, and direct CLI usage). Set it in your MCP client env config or export it before running sahmk-mcp.
Optional: SAHMK_BASE_URL overrides the default public Developer API host.
Default REST base URL is https://api.sahmk.sa/api/v1/ (aligned with sahmk SDK 0.17.0). https://app.sahmk.sa/api/v1/ remains a fully supported compatibility host — set SAHMK_BASE_URL if you need it:
export SAHMK_BASE_URL="https://app.sahmk.sa/api/v1" Path shapes are unchanged (/api/v1/, /api/v2/, /ws/v1/). Portal/dashboard routes (/api/developers/*) stay on app.sahmk.sa and are not used by this MCP.
pip install sahmk-mcp Requires sahmk>=0.21.0 for current MCP-SDK compatibility (default host api.sahmk.sa, market depth, live trades with session recovery, events, canonical historical intervals, and portfolio tools).
Set API keys via environment variables (SAHMK_API_KEY).
Never commit keys to source control or share them in logs.
Rotate exposed keys immediately from your Sahmk dashboard.
Add to ~/Library/Application Support/Claude/claude_desktop_config.json:
{ "mcpServers": { "sahmk": { "command": "sahmk-mcp", "env": { "SAHMK_API_KEY": "your_api_key" } } } } Optional compatibility host override (same paths on app.sahmk.sa):
Add to .cursor/mcp.json:
export SAHMK_API_KEY="your_api_key" sahmk-mcp Tool Input Constraints
get_market_summary.index: TASI or NOMU (NOMUC alias is accepted and normalized).
get_market_movers.type: gainers, losers, volume, or value.
get_market_movers.limit: integer from 1 to 50.
get_quote.identifier (preferred): accepts numeric symbol, Arabic/English company name, or known alias.
get_quote.symbol (legacy alias): accepted for backward compatibility.
get_quotes.identifiers (preferred): maximum 50 identifiers per request.
get_quotes.symbols (legacy alias): accepted for backward compatibility.
get_financials.symbol: prefers exact exchange symbol; MCP attempts SDK-backed identifier resolution for names/aliases when possible.
get_financials.period and get_financials.statement_period: if both are provided, period takes precedence.
get_financials supports optional passthrough params: type, period, statement_period, history, metrics, result, and include_partial.
get_financials response is statement-block focused and does not include meta.
get_ratios.symbol: prefers exact exchange symbol; MCP attempts SDK-backed identifier resolution for names/aliases when possible.
get_ratios.history: defaults to latest.
get_ratios.period: defaults to annual.
get_ratios.metrics: defaults to core.
compare_symbols.symbols: list of symbols (preferred) or comma-separated string; MCP attempts SDK-backed identifier resolution for names/aliases when possible.
compare_symbols.metrics: defaults to core.
get_ratios and compare_symbols include minimal meta only: period, metrics, warnings.
Analytics tools do not expose backend/internal fields such as applied_profile, plan, or source diagnostics.
get_dividends.symbol: prefers exact exchange symbol; MCP attempts SDK-backed identifier resolution for names/aliases when possible.
get_depth.symbol: prefers exact exchange symbol; MCP attempts SDK-backed identifier resolution for names/aliases when possible.
get_depth.levels: optional integer from 1 to 20 (backend default is typically 5; entitlement may cap below the request).
get_trades.symbol: prefers exact exchange symbol; MCP attempts SDK-backed identifier resolution for names/aliases when possible.
get_trades.limit: optional integer from 1 to 200 (backend default is typically 50).
get_trades.date: optional YYYY-MM-DD (Asia/Riyadh). Reads one session from the recent tape (about three days) in receive order and adds a page object. Without it, prints are newest first.
get_trades.after_seq: optional non-negative integer; only prints with a greater trade_seq. Requires date. A filter, not a cursor.
get_trades.cursor: optional page.next_cursor from the previous page. Requires date. Follow it while page.has_more is true.
get_trades.events[].side: optional trade side, one of buy, sell, or null.
get_events.symbol: optional exact exchange symbol filter; omit for market-wide recent events.
get_events.limit: optional integer from 1 to 100.
get_historical.symbol: prefers exact exchange symbol; MCP attempts SDK-backed identifier resolution for names/aliases when possible.
companies_list.market: TASI or NOMU (NOMUC alias is accepted and normalized).
companies_list.limit: integer greater than 0.
companies_list.offset: integer greater than or equal to 0.
companies_list.accumulated_losses: flagged, not_flagged, unknown, not_applicable, or a band (20_35, 35_50, 50_plus). Each row carries screening.accumulated_losses with status and band; Starter and above also get percent_of_capital, as_of, and source. unknown means no disclosure in the last 12 months, not a confirmed absence of a flag. ETFs, closed-end funds, and Sukuk are not_applicable.
get_historical.interval: 1min, 5min, 15min, 30min, 60min, 1d, 1w, or 1mo (default 1d). A 1w bar is one Saudi trading week, Sunday to Thursday (Saturday to Wednesday before 30 June 2013). Legacy aliases 30m, 60m, and 1m are accepted; 1m means one month, not one minute.
get_historical.adjustment: capital (default) is the exchange Performance Summary print, adjusted for bonus shares, splits, and rights; cash dividends are not removed. none is unadjusted prices: the exchange Unadjusted Prices & Volume tab up to the capture's last session, and SAHMK's end-of-day bars after it. Same fields either way; adjusted_close stays the capital-adjusted close. Daily, weekly, and monthly bars only; intraday bars are as traded. The response's adjustment field says which series was served. A symbol without unadjusted history returns HTTP 422 UNADJUSTED_UNAVAILABLE.
Portfolio tools take portfolio_id as a positive integer from get_portfolios.
create_portfolio_transaction: single mode needs transaction_type (deposit, buy, sell, withdrawal, dividend, fee) and amount_sar; batch mode sends transactions plus batch_idempotency_key and no single-mode fields. Entries dated before the latest executed_at are rejected.
set_portfolio_holdings: scope is full or partial; cash_policy is auto_fund or require_cash; dry_run defaults to true; applying needs the dry run's plan_token.
Ambiguous identifiers raise AMBIGUOUS_IDENTIFIER with retry guidance and candidates when available.
Invalid identifiers and plan-gated requests return the underlying API error.
Company directory search: companies_list(search="aramco")
Company directory by market alias normalization: companies_list(search="acwa", market="NOMUC")
Company directory pagination: companies_list(search="bank", limit=50, offset=100)
Preferred single quote call: get_quote(identifier="أرامكو")
Legacy single quote call: get_quote(symbol="2222")
Preferred batch quote call: get_quotes(identifiers=["سبكيم", "كيان"])
Legacy batch quote call: get_quotes(symbols=["2222", "1120"])
Financials by exact symbol: get_financials(symbol="1120")
Financial ratios defaults: get_ratios(symbol="1120")
Financial ratios advanced: get_ratios(symbol="1120", history="5y", period="quarterly", metrics="extended")
Compare symbols defaults: compare_symbols(symbols=["1120", "1180", "1010"])
Compare symbols extended: compare_symbols(symbols=["1120", "1180", "1010", "2222"], metrics="extended")
Dividends by exact symbol: get_dividends(symbol="1120")
Market depth by exact symbol: get_depth(symbol="2222")
Market depth with levels: get_depth(symbol="2222", levels=10)
Recent trades by exact symbol: get_trades(symbol="2222")
Recent trades with limit: get_trades(symbol="2222", limit=20)
One session, first page: get_trades(symbol="2222", date="2026-11-22", limit=200)
Next page: get_trades(symbol="2222", date="2026-11-22", cursor="
Prints after a known sequence: get_trades(symbol="2222", date="2026-11-22", after_seq=204505)
Trades event side is additive and optional: each events[] item may include side = buy, sell, or null.
Recent market events: get_events(limit=10)
Events for one symbol: get_events(symbol="1120", limit=5)
Historical by exact symbol: get_historical(symbol="1120", interval="1d")
Historical with explicit daily date range args: get_historical(symbol="1120", from_date="2026-01-01", to_date="2026-03-31", interval="1d")
Intraday historical by exact symbol (plan-gated by API key): get_historical(symbol="1120", interval="60min")
One-minute bars: get_historical(symbol="2222", interval="1min")
Monthly bars: get_historical(symbol="2222", interval="1mo")
List portfolios: get_portfolios()
Portfolio P&L: get_portfolio_summary(portfolio_id=12)
Record a buy: create_portfolio_transaction(portfolio_id=12, transaction_type="buy", symbol="2222", quantity=100, unit_price_sar=26.6, amount_sar=2660, idempotency_key="buy-2222-1")
Preview a reconcile: set_portfolio_holdings(portfolio_id=12, scope="partial", cash_policy="auto_fund", holdings=[{"symbol": "2222", "quantity": 100, "avg_cost_sar": 26.0}])
Intraday historical with explicit date range args: get_historical(symbol="1120", from_date="2026-05-01", to_date="2026-05-31", interval="60m")
Company Directory / Symbol Discovery
Use companies_list first to reduce invalid-symbol 404s before symbol-only tools.
Discover candidates by name or symbol fragment: companies_list(search="aramco")
companies_list(search="2222")
Optionally scope discovery by market: companies_list(search="acwa", market="NOMUC") (NOMUC is normalized to NOMU)
Pick a symbol from results, then call: get_quote(identifier="
get_financials(symbol="
get_dividends(symbol="
get_historical(symbol="
For pagination loops, increment offset by limit until you reach total: companies_list(search="bank", limit=100, offset=0)
companies_list(search="bank", limit=100, offset=100)
continue until offset >= total
MCP Guidance Examples
User: "سعر الراجحي" -> call get_quote(identifier="الراجحي").
Follow-up: "قوائم الشركة" -> if previous result includes resolved_instrument.symbol = "1120", reuse it and call get_financials(symbol="1120").
"Give me a TASI summary and market mood."
"Give me TASI market movers by gainers."
"Give me NOMU market movers by value."
"Show me sector performance."
"Compare سابك, سبكيم, and 2222 by price change and net liquidity."
"Show me NOMU summary for today."
"Get financials for 2222."
"Get dividends for 2222."
"Show me the order book / market depth for 2222."
"Show me the latest trades for 2222."
"What are the latest stock events?"
"Get 1d historical data for 1120 from 2026-01-01 to 2026-03-31."
"Tell me about الراجحي and its sector."
Note: get_financials and get_dividends require Sahmk API access on Starter or higher. If unavailable for the current key, the MCP returns the underlying API error. Note: get_depth is entitlement-gated — request access. get_trades and get_events require Pro+. If unavailable for the current key, the MCP surfaces the API error. Note: historical intervals are plan-gated. Starter gets 1d/1w/1mo; Pro adds 15min/30min/60min; Business adds 5min; 1min is Enterprise where enabled. Intraday date windows are limited by plan. A valid interval outside the plan, or a range past its window, returns 403 PLAN_LIMIT. If unavailable for the current key, the MCP surfaces the API error (for example 403 PLAN_LIMIT).
0.13.0: require sahmk>=0.21.0; get_historical documents the response's adjustment field, the 422, and that cash dividends are not removed.
0.12.0: require sahmk>=0.20.0; companies_list.accumulated_losses accepts not_applicable (ETFs, closed-end funds, Sukuk); get_historical documents Saudi trading weeks for 1w.
0.11.0: require sahmk>=0.19.0; companies_list adds accumulated_losses (status or band filter), and rows carry screening.accumulated_losses.
0.10.0: require sahmk>=0.18.0; get_historical adds adjustment (capital default, or none for the exchange Unadjusted Prices & Volume tab).
0.9.0: require sahmk>=0.17.0; get_historical accepts the canonical intervals (1min, 5min, 15min, 30min, 60min, 1d, 1w, 1mo) plus legacy aliases; get_trades adds date, after_seq, and cursor for session recovery and returns trade_seq and page; add the nine portfolio tools available on the hosted server.
0.8.1: bump minimum sahmk SDK requirement to 0.16.0.
0.8.0: add optional side to get_trades events (buy/sell/null) with backward-compatible output for payloads that omit it.
0.7.0: default public Developer API host → api.sahmk.sa (require sahmk>=0.15.0); app.sahmk.sa still supported via SAHMK_BASE_URL.
0.6.0: require sahmk>=0.14.0; add get_trades for recent live trade prints (Pro+).
0.5.1: document market-depth entitlement request link in the README.
0.5.0: require sahmk>=0.13.0; add get_depth (order-book ladder) and get_events (AI event summaries, Pro+).
0.4.7: remove include_quality from public get_financials tool contract, normalize equivalent Arabic-Indic/ASCII digit inputs before identifier conflict checks, and improve Glama form UX with enum selectors for stable ratio/period options.
0.4.6: add SDK-backed identifier fallback for get_company and symbol-first tools (get_financials, get_ratios, compare_symbols, get_dividends, get_historical) when name/alias inputs fail direct symbol lookup.
0.4.5: align to sahmk>=0.11.0; extend get_historical.interval support to 30m/60m; document intraday plan-gating behavior.
0.4.4: docs: clarify official distribution channels (GitHub + PyPI only)
0.4.3: Align MCP output contract: no financials meta; analytics meta is limited to period, metrics, and warnings.
0.4.2: Add SDK method-name compatibility fallback for analytics (get_ratios/ratios, compare_symbols/compare).
0.4.1: Require sahmk>=0.9.1 in package dependency and runtime version guard.
0.4.0: Add analytics ratios and compare tools; enhance financials optional parameters.
Released: Dec 5, 2026
ai-agents market-data mcp sahmk saudi-market stocks
Development Status 4 - Beta
Intended Audience Developers
License OSI Approved :: MIT License
Programming Language Python :: 3
Topic Office/Business :: Financial
Software Development :: Libraries :: Python Modules
Release files for sahmk-mcp 0.13.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
Built distribution (wheel)
Total release size: 55.0 kB
Release files / sahmk_mcp-0.13.0.tar.gz
Release files / sahmk_mcp-0.13.0-py3-none-any.whl
Security for sahmk-mcp 0.13.0
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.
Release history Release notifications | RSS feed
Dec 5, 2026 2 release files No provenance
Dec 4, 2026 2 release files No provenance
Nov 29, 2026 2 release files No provenance
Nov 26, 2026 2 release files No provenance
Aug 25, 2026 2 release files No provenance
Aug 3, 2026 2 release files Loss of provenance
Jul 29, 2026 2 release files Loss of provenance
Jul 25, 2026 2 release files Full provenance
Jul 10, 2026 2 release files Full provenance
May 31, 2026 2 release files Full provenance
May 3, 2026 2 release files Full provenance
Apr 29, 2026 2 release files Full provenance
Apr 25, 2026 2 release files Full provenance
Apr 23, 2026 2 release files Full provenance
Apr 18, 2026 2 release files Full provenance
Apr 14, 2026 2 release files Full provenance
Apr 12, 2026 2 release files Full provenance
Apr 2, 2026 2 release files No provenance
"PyPI", "Python Package Index", and the blocks logos are registered trademarks of the Python Software Foundation.
© 2026 Python Software Foundation
Deployed from 4d99e05











