WorldQuant BRAIN (unofficial)

io.github.tukorama由 GitHub 账号 tukorama 发布v0.2.1更新于 Nov 12, 2026

Simulate and backtest alphas on WorldQuant BRAIN, browse data fields and operators. Unofficial.

发布方自己的服务:BrainDog

已验证STDIO仅桌面金融数据与分析

概览

AI 生成的概览

非官方的 WorldQuant BRAIN 服务器,让助手浏览数据字段与算子、回测 FASTEXPR alpha 并查看结果。

可以做什么
  • 浏览账户可用的数据集、数据字段、分类与算子
  • 回测单个表达式或最多 30 个表达式的批次,并查询或续接模拟状态
  • 搜索 alpha,读取其表达式、设置、统计、按年 PnL 与 recordset
  • 运行提交前检查以及自身相关性与生产池相关性测试
  • 修改 alpha 的名称、描述、标签、分类等元数据
  • 读取用户资料、活动计数与平台消息
适用场景
适合在 WorldQuant BRAIN 上做量化信号研究时使用,让助手查找数据字段、运行并迭代回测、为提交做准备。适用于已有 BRAIN 账户并了解其模拟配额的用户。
运行要求
以 Python 包形式通过 uvx 在本地运行(stdio)。需要 WorldQuant BRAIN 账户:可用 auth 命令登录一次,或提供 WQB_EMAIL 与 WQB_PASSWORD,或通过 WQB_CREDENTIALS_FILE 指定凭据文件。需要访问 BRAIN API 的网络。除非将 WQB_ALLOW_SUBMIT 设为 true,否则不提供提交功能。
安装前请注意
模拟会消耗有限且计量的配额,且耗时数分钟;本地账本会避免重复运行。提交不可撤销,仅在 WQB_ALLOW_SUBMIT 为 true 时开放,并带有可关闭的自身相关性门槛。凭据以明文保存在凭据文件中,除非改用来自自有密钥库的 WQB_EMAIL 与 WQB_PASSWORD。部分工具会更改账户状态;该服务器为非官方项目,与 WorldQuant 无关联。

安装

在 SourceWeft 中

  1. 打开 控制台中的 WorldQuant BRAIN (unofficial),将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

MCP server and LangGraph tools for WorldQuant BRAIN

[PyPI] [CI] [License: MIT]

mcp-server-worldquantbrain is a Model Context Protocol (MCP) server for the WorldQuant BRAIN API, with the same tools packaged for LangGraph and LangChain. It lets an agent look up data fields, backtest Fast Expression (FASTEXPR) alphas and read the results. Unofficial, and not affiliated with WorldQuant.

Why this exists

Driving BRAIN from an agent goes wrong in a few predictable ways, and each one shaped this package.

  • A simulation takes minutes and clients give up sooner. A wait that runs out returns PENDING with an id, and get_simulation_status picks it up again. Nothing is resubmitted.
  • Agents repeat themselves, and simulations are metered. A local ledger remembers every expression and settings pair, so a repeat returns the earlier alpha instead of spending quota.
  • BRAIN responses are huge. Tools return trimmed, typed results: a PnL series becomes yearly figures, lists are paged and capped, and messages lose their embedded images.
  • Logging in is awkward. The session is saved to disk, so restarts and short-lived stdio processes reuse it. If BRAIN asks for a biometric check you get a URL to open, not a headless browser you cannot see.
  • Submission is permanent. submit_alpha does not exist unless you turn it on, and when it is on it runs BRAIN's checks and the self-correlation test first and refuses on any failure.

Quick start

Store your login once. Credentials go to ~/.config/mcp-server-worldquantbrain/credentials.json, readable only by you.

bash
uvx mcp-server-worldquantbrain auth

Then add the server to your client.

Claude Code

bash
claude mcp add brain -- uvx mcp-server-worldquantbrain

Claude Desktop, Cursor, VS Code and others

json
{  "mcpServers": {    "brain": { "command": "uvx", "args": ["mcp-server-worldquantbrain"] }  }}

Now ask for something like "Find a value signal in the fundamental datasets for USA TOP3000 and backtest it."

Prefer to pass credentials directly? Add "env": {"WQB_EMAIL": "...", "WQB_PASSWORD": "..."}.

LangGraph and LangChain

The langgraph extra gives you plain LangChain tools in the same process, with no MCP server to run. It also has a prebuilt agent.

bash
uv add "mcp-server-worldquantbrain[langgraph]"
python
from mcp_server_worldquantbrain.integrations.langgraph import create_brain_agent, get_brain_tools
agent = create_brain_agent("anthropic:claude-sonnet-5")result = await agent.ainvoke({"messages": [("user", "Backtest rank(-returns) and summarize it")]})
# Or take the tools and build your own graph:tools = get_brain_tools()

The tools work from sync and async graphs. With WQB_ALLOW_SUBMIT=true the agent stops for human approval before submit_alpha. Invoke it with a thread_id in the config, and resume with Command(resume=...). get_brain_tools() leaves submit_alpha out, because a custom graph has no approval step; pass include_submit=True once yours does.

To keep BRAIN in a separate process, connect over MCP instead. This route needs langchain[mcp], which LangChain still marks as beta.

python
from langchain.agents import create_agentfrom langchain.mcp import MCPAdapter
config = {    "mcpServers": {        "brain": {            "command": "uvx",            "args": ["mcp-server-worldquantbrain"],            "timeout": 1_200_000,  # milliseconds; simulations block        }    }}
async with MCPAdapter(config) as adapter:    agent = create_agent("anthropic:claude-sonnet-5", await adapter.list_tools())

The subprocess inherits only HOME, PATH and a few others, so anything else, including WQB_* variables, has to go in env. Over this route a submission confirmation arrives as a LangGraph interrupt, so give the agent a checkpointer if you enable submission. A deployable example is in examples/langgraph_app.

draw_mermaid(agent) from mcp_server_worldquantbrain.integrations.langgraph returns the graph as a Mermaid flowchart, for the prebuilt agent or a graph of your own. Tools are grouped by area and colored by what they can change. This is the prebuilt agent with WQB_ALLOW_SUBMIT=true:

mermaid
---config:  flowchart:    nodeSpacing: 24    rankSpacing: 12    padding: 8---flowchart TB    subgraph agent["Agent graph"]        direction LR        n0([start])        n1["model"]        n2["tools"]        n3{{"human approval<br/>before submit_alpha"}}:::approval        n4([end])        n3 -.-> n4        n3 -.->|"rejected"| n1        n3 -.->|"approved"| n2        n0 --> n1        n1 --> n3        n2 -.-> n1    end    subgraph tools["Tools"]        direction TB        subgraph tools_row0[" "]            direction LR            subgraph tools_auth["Login"]                direction LR                tools_auth_read["auth_status"]:::read                tools_auth_write["authenticate<br/>complete_authentication"]:::write            end            subgraph tools_simulations["Simulate"]                direction LR                tools_simulations_read["get_simulation_status<br/>get_simulation_options"]:::read                tools_simulations_write["simulate_alpha<br/>simulate_alphas_batch"]:::write            end            subgraph tools_submit["Submit"]                direction LR                tools_submit_irreversible["submit_alpha"]:::irreversible            end            tools_auth ~~~ tools_simulations ~~~ tools_submit        end        subgraph tools_row1[" "]            direction LR            subgraph tools_alphas["Alphas"]                direction LR                tools_alphas_read["get_alpha<br/>list_alphas<br/>get_alpha_pnl<br/>list_alpha_recordsets<br/>get_alpha_recordset<br/>check_alpha_submission<br/>get_alpha_self_correlation<br/>get_alpha_prod_correlation"]:::read                tools_alphas_write["update_alpha"]:::write            end            subgraph tools_data["Data"]                direction LR                tools_data_read["list_datasets<br/>get_dataset<br/>list_datafields<br/>get_datafield<br/>list_data_categories<br/>list_operators"]:::read            end            subgraph tools_users["Account"]                direction LR                tools_users_read["get_user_profile<br/>get_user_activity<br/>list_messages"]:::read            end            tools_alphas ~~~ tools_data ~~~ tools_users        end        tools_row0 ~~~ tools_row1    end    agent -- tool calls --> tools    subgraph legend["Legend"]        direction TB        legend_read["read-only"]:::read        legend_write["changes account state"]:::write        legend_irreversible["irreversible"]:::irreversible    end    brain["BRAIN API"]:::external    tools -- HTTPS --> brain    tools ~~~ legend    classDef default fill:#64748b,fill-opacity:0.06,stroke:#64748b    classDef read fill:#64748b,fill-opacity:0.14,stroke:#64748b    classDef write fill:#d97706,fill-opacity:0.16,stroke:#d97706    classDef irreversible,approval fill:#dc2626,fill-opacity:0.16,stroke:#dc2626,stroke-width:2px    classDef external fill-opacity:0,stroke-dasharray:5 4    classDef box fill:#64748b,fill-opacity:0.05,stroke:#64748b,stroke-opacity:0.45    classDef row fill:none,stroke:none    class agent,tools,tools_auth,tools_simulations,tools_submit,tools_alphas,tools_data,tools_users,legend box    class tools_row0,tools_row1 row

Tools

GroupToolNotes
Loginauthenticate, complete_authentication, auth_statusOther tools log in by themselves
Simulatesimulate_alphaBlocks up to 15 minutes by default; wait=False returns at once
simulate_alphas_batchUp to 30 expressions, in groups of 10; needs multi-simulation access
get_simulation_statusCheck or resume a simulation
get_simulation_optionsRegions, universes and delays your account can use
Alphasget_alpha, list_alphasFilter by Sharpe, fitness, turnover, date, tag and more
get_alpha_pnl, list_alpha_recordsets, get_alpha_recordsetPnL by year; other recordsets as rows
update_alphaName, description, tags, color, category
check_alpha_submissionBRAIN's pre-submission checks
get_alpha_self_correlation, get_alpha_prod_correlationProduction correlation depends on account tier
submit_alphaOff unless WQB_ALLOW_SUBMIT=true
Datalist_datasets, get_dataset, list_datafields, get_datafield
list_data_categories, list_operators
Accountget_user_profile, get_user_activity, list_messagesPersonal fields are withheld by default

Resources: brain://operators, brain://simulation-options, brain://alphas/{alpha_id}, and reference pages under brain://docs/ (fastexpr-cheatsheet, settings-guide, submission-criteria).

Prompts: design_alpha runs a short research loop. review_alpha assesses an existing alpha.

Configuration

All settings are environment variables. A .env file in the working directory also works, except for settings that decide where credentials go or that enable submission (WQB_BASE_URL, the file and directory paths, the WQB_SUBMIT_* and WQB_ALLOW_SUBMIT settings, and the bearer token). These have to be set in the real environment.

VariableDefaultPurpose
WQB_EMAIL, WQB_PASSWORDLogin. These win over the credentials file
WQB_CREDENTIALS_FILE~/.config/mcp-server-worldquantbrain/credentials.jsonJSON: ["email", "password"]
WQB_SESSION_FILE~/.config/mcp-server-worldquantbrain/session.jsonSaved session. Delete it to log out
WQB_CACHE_DIR~/.cache/mcp-server-worldquantbrainCatalogue cache and simulation ledger
WQB_CACHE_TTLper catalogueSeconds; 0 disables the cache
WQB_LEDGERtrueReuse results of identical simulations
WQB_ALLOW_SUBMITfalseExpose submit_alpha
WQB_SUBMIT_CONFIRMelicitAsk the user first where the client supports it; none skips asking
WQB_SUBMIT_CORRELATION_GATE0.7Refuse at or above this self-correlation; 0 disables
WQB_MAX_CONCURRENT_SIMULATIONS2Blocking simulation calls this process runs at once
WQB_SIMULATION_TIMEOUT900Seconds a blocking simulation waits
WQB_HTTP_TIMEOUT30Seconds per HTTP request
WQB_POLL_MAX_INTERVAL30Longest pause between status polls
WQB_HTTP_BEARER_TOKENRequired by the HTTP transport on a non-local address
WQB_LOG_LEVELINFOLogs go to stderr
WQB_DEFAULT_REGION, WQB_DEFAULT_UNIVERSE, _DELAY, _DECAY, _NEUTRALIZATION, _TRUNCATION, _PASTEURIZATION, _UNIT_HANDLING, _NAN_HANDLING, _TEST_PERIOD, _MAX_TRADE, _INSTRUMENT_TYPEUSA, TOP3000, 1, 0, INDUSTRY, 0.08, ON, VERIFY, OFF, none, OFF, EQUITYUsed when a call leaves a setting out. A call for another region must name its universe

On Windows the two directories are %APPDATA%\mcp-server-worldquantbrain and %LOCALAPPDATA%\mcp-server-worldquantbrain, and files are protected by your user profile rather than POSIX permissions.

To serve over HTTP:

bash
WQB_HTTP_BEARER_TOKEN=change-me mcp-server-worldquantbrain serve --transport streamable-http --host 0.0.0.0

The server refuses a non-local address without a token. /health stays open for probes.

How it behaves

Long calls. Claude Desktop has been reported to cancel stdio tool calls after about a minute, so for that client each call is limited to 45 seconds of waiting and the agent resumes with get_simulation_status. Claude Code and LangGraph wait as long as you let them. Set WQB_SIMULATION_TIMEOUT to match whatever your client allows.

Concurrency. BRAIN limits simultaneous simulations per account and does not publish the number. The default of 2 is deliberately cautious. Raise it if your account allows more. The setting only counts blocking calls while they wait, and one batch group of up to 10 uses one slot. wait=False calls, simulations still running after a timeout, and other processes on the same account are not counted, and can hit BRAIN's own limit, which comes back as a rate-limit error with a suggested wait.

The ledger. Whitespace in an expression does not matter; every setting does. Pass force=True to run an identical simulation again. Failed simulations can be run again.

Writes are not retried. A POST that may have reached BRAIN is never repeated automatically, so a network failure cannot spend quota twice or submit twice. Reads retry with backoff and honour Retry-After.

Biometric login. authenticate returns a URL, the user finishes the check in a browser, and complete_authentication ends the login. The pending check is saved for 30 minutes, so it survives a restart. On a terminal, mcp-server-worldquantbrain auth does the same with a prompt.

What is cached. Operators and simulation options for a week, categories and dataset pages for a day. Alphas, simulations, checks, correlations and data fields are always fetched fresh.

What is never logged. Passwords, cookies, authorization headers and session tokens are masked, and email addresses are shortened, in logs and error messages.

Limitations

  • BRAIN's API documentation sits behind a login, and BRAIN can change the API without notice. Run WQB_LIVE=1 uv run pytest -m live to check it against your account.
  • Login, saved sessions, data catalogues, single simulations, alpha search, PnL, recordsets, submission checks and self-correlation have been run against a live account. Biometric completion, multi-simulation, update_alpha, submit_alpha and production correlation results have only been tested against responses documented by other BRAIN clients, so treat them as less proven. If a biometric completion fails, log in once on the BRAIN website and call authenticate with force=true.
  • The self-correlation gate fails closed: if BRAIN will not report the figure, submit_alpha refuses. Set WQB_SUBMIT_CORRELATION_GATE=0 on accounts where that endpoint is unavailable.
  • Simulations are REGULAR FASTEXPR alphas. SUPER and region-agnostic alphas, Python alphas, forum access, payments, competitions and pyramids are not covered.
  • There is no cancel tool, because no cancel endpoint is known.
  • credentials.json is plaintext protected by file permissions. Use WQB_EMAIL and WQB_PASSWORD from your own secret store if that is not enough.
  • Check that your use of automation complies with the BRAIN terms that apply to you.

Other WorldQuant BRAIN projects

  • cnhkmcp is on PyPI and covers far more of the platform, including the forum. It is a large install that bundles Selenium.
  • lavender1203/world-quant-brain-mcp has the deepest local analytics, such as correlation pools and an alpha history database. It runs with Docker and Redis over HTTP, and has no license.
  • QuantGPT is a full research agent with its own knowledge base, for when you want the loop rather than the tools.
  • worldquant-harness adds local backtests and a strict human submission boundary.
  • brainapi-go-sdk is a Go SDK and CLI with static binaries and tests built on captured API responses.
  • rocky-d/wqb is a plain Python client, if you do not need an agent interface.

No code in this repository was copied from those projects.

Development

To point a client at a checkout, use uvx --from /path/to/mcp-server-worldquantbrain mcp-server-worldquantbrain, or uv add --editable ../mcp-server-worldquantbrain from your LangGraph project. See CONTRIBUTING.md and RELEASING.md.

License

MIT

来源:README.md,提交 70e3d25

工具

25

get_alpha

Get an alpha

Return an alpha's expression, settings, in-sample stats and submission checks.

输入参数alpha_id必填

list_alphas

List my alphas

Search the user's alphas. Use next_offset to page; BRAIN stops at offset 10,000.

输入参数tagnamecolordelaylimitorderhiddenoffsetregionstatuscategoryfavorite另有 8 个

get_alpha_pnl

Get alpha PnL

Summarize an alpha's PnL by year, with optional recent daily cumulative values.

输入参数last_nalpha_id必填include_daily

list_alpha_recordsets

List alpha recordsets

List the recordset names available for an alpha, for use with get_alpha_recordset.

输入参数alpha_id必填

get_alpha_recordset

Get an alpha recordset

Return one recordset as named rows. Prefer get_alpha_pnl for PnL.

输入参数name必填alpha_id必填max_rows

update_alpha

Update alpha properties

Change an alpha's name, description, tags, color, category, favorite or hidden flag.

输入参数nametagscolorhiddenalpha_id必填categoryfavoritedescription

check_alpha_submission

Run submission checks

Run BRAIN's pre-submission checks. verdict is PASS, WARNING, FAIL or PENDING.

输入参数alpha_id必填wait_seconds

get_alpha_self_correlation

Get self-correlation

Return the alpha's highest correlation with the user's submitted alphas (limit 0.7).

输入参数alpha_id必填wait_seconds

get_alpha_prod_correlation

Get production correlation

Return the alpha's correlation with the production pool. Some account tiers get a 403.

输入参数alpha_id必填wait_seconds

authenticate

Log in to BRAIN

Log in with the configured credentials, reusing a saved session when it is still valid. Tools log in on their own, so this is only needed to start or restart a biometric check. When state is biometric_required, have the user open biometric_url, then call complete_authentication.

输入参数force

complete_authentication

Finish a biometric login

Finish a login after the user completed the biometric check at biometric_url.

无需输入参数。

auth_status

Check the BRAIN session

Report whether a BRAIN session is active and when it expires. Never sends the password.

无需输入参数。

list_datasets

List datasets

List datasets available for a market. Cached for a day.

输入参数delaylimitorderthemeoffsetregionsearchcategoryuniverseinstrument_type

get_dataset

Get a dataset

Return one dataset with its full description, for example dataset_id 'pv1'.

输入参数dataset_id必填

list_datafields

List data fields

Find the data fields usable in expressions. BRAIN stops paging at 10,000 rows, so when truncated_by_api is true narrow with dataset_id or search.

输入参数typedelaylimitorderoffsetregionsearchcategoryuniversedataset_idinstrument_type

get_datafield

Get a data field

Return one data field with its full description, for example field_id 'close'.

输入参数field_id必填

list_data_categories

List data categories

Return the data category tree. Cached for a day.

无需输入参数。

list_operators

List operators

List the FASTEXPR operators this account can use. Cached for a week.

输入参数searchverbosecategory

simulate_alpha

Simulate an alpha

Backtest one FASTEXPR expression and return its alpha with stats and checks. A simulation usually takes 1 to 10 minutes. If it outlasts the timeout the result has status PENDING and a simulation_id: call get_simulation_status to resume, never simulate again. Identical expression and settings return the earlier result (from_ledger) without spending quota. ERROR or FAIL results carry BRAIN's message, usually a syntax or field problem.

输入参数waitdecaydelayforceregionuniversemax_tradeexpression必填truncationtest_periodnan_handlingunit_handling另有 4 个

simulate_alphas_batch

Simulate several alphas

Backtest up to 30 expressions, sent to BRAIN in groups of at most 10. All expressions must share one delay; different regions are sent as separate groups. Multi-simulation needs a Consultant account. Expressions already in the ledger are returned without spending quota. not_started lists anything that could not be sent; resubmit those later.

输入参数waitforcealphas必填timeout_seconds

get_simulation_status

Get simulation status

Check or resume a simulation. A finished one includes its alpha; a batch lists children.

输入参数wait_secondssimulation_id必填

get_simulation_options

List valid simulation settings

List the regions, universes, delays and neutralizations this account may simulate. by_context maps parent settings such as 'EQUITY:USA' to the values valid for them. Cached for a week.

无需输入参数。

get_user_profile

Get my profile

Return the user's BRAIN profile. Personal fields are withheld by default.

输入参数include_pii

get_user_activity

Get my activity

Return simulation or submission counts: yesterday, month to date, year to date, total.

输入参数kind必填

list_messages

List my messages

Return platform messages, newest first, as plain text capped at 2,000 characters each.

输入参数typelimitoffset

版本历史

1
  1. v0.2.1最新Nov 12, 2026

评分

已满足适用检查项的 90%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分
  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具必需15 分
  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分

其他 Brain 集成