
kFinance
MCP标普全球旗下 Kensho 官方的 kFinance 库与 MCP 服务,让 AI 查询 S&P Capital IQ 的公司财报、股价与市值、分析师一致预期、并购与融资、业绩会纪要等数据,适合投研与财务分析。需标普 LLM-ready API 订阅或试用账号;输出需专业人员核对。
kFinance
The kFinance Python library provides a simple interface for the LLM-ready API, streamlining API requests and response handling. It can be used on its own, with LLMs, or integrated into applications.
For a complete overview of the functions, usage, and features of the kFinance Python library, please refer to documentation here.
Any questions or suggestions can be sent to the kFinance Maintainers.
Setup
You can install kFinance on PyPI via
pip install kensho-kfinance
Getting started
To receive access, please email S&P Global Market Intelligence for information on free trials and pricing.
Once access is obtained, get started using the Authentication Guide and Usage Guide.
To get started, we provide some notebooks:
- The LLM-ready API Basic Usage notebook demonstrates how fetch data with the kFinance client.
- The tool_calling notebooks show how the kFinance library can be used for tool calling. We provide notebooks for OpenAI (GPT), Anthropic (Claude), and Google (Gemini). Each of these integrations comes in a langchain version, which uses langchain as a wrapper to simplify the integration, and as a lower level non-langchain version.
We also provide an interactive notebook that demonstrates some usage examples.
MCP (Model Context Protocol)
To run the kFinance MCP server use:
python -m kfinance.mcp
This function initializes and starts an MCP server that exposes the kFinance tools. The server supports multiple authentication methods and transport protocols to accommodate different deployment scenarios.
The server's full signature is as follows:
kfinance.mcp [--stdio|-s|--sse|--streamable-http] --refresh-token <refresh-token> --client-id <client-id> --private-key <private-key> --kid <kid> --api-host <api-host>
Authentication Methods (in order of precedence):
- Refresh Token: Uses an existing refresh token for authentication. The
--refresh-token <refresh-token>argument must be provided. - Key Pair: Uses client ID and private key for authentication. Both the
--client-id <client-id>and--private-key <private-key>arguments must be provided. Add--kid <kid>when more than one public key is registered, since Okta rejects an assertion without a key ID in that case. - Browser: Falls back to browser-based authentication flow. This occurs if no auth arguments are provided.
Transport Layers:
--stdio/-s: Standard input/output transport (use with MCP Inspector)--sse: Server-Sent Events transport (default)--streamable-http: HTTP transport
API Host:
--api-host <api-host>: The kFinance API host to fetch data from. Defaults to production (https://kfinance.kensho.com). Useful for pointing the server at a local or pre-production backend.- Refresh tokens are redeemed against
--api-host, so a token issued by one host will not authenticate against another. Key-pair authentication goes to Okta instead, and so works against any host.
Examples:
# Using stdio with MCP Inspector
npx @modelcontextprotocol/inspector python -m kfinance.mcp --stdio --refresh-token <token>
# Using SSE (default)
python -m kfinance.mcp --refresh-token <token>
# Using streamable-http
python -m kfinance.mcp --streamable-http --refresh-token <token>
# Against a locally running backend
python -m kfinance.mcp --stdio --api-host http://localhost:8000 --refresh-token <token>
MCP Proxy
The kFinance MCP proxy is a skeleton server that forwards requests to a remote kfinance MCP backend, injecting authentication tokens into every outgoing request. It is intended as a starting point for building a full production MCP proxy service.
# Using a refresh token (for experimentation)
AUTH_REFRESH_TOKEN=<token> python -m kfinance.proxy_mcp
# Using a key pair (for production)
AUTH_CLIENT_ID=<client-id> AUTH_PRIVATE_KEY=<private-key> python -m kfinance.proxy_mcp
# Add AUTH_KID when more than one public key is registered
AUTH_CLIENT_ID=<client-id> AUTH_PRIVATE_KEY=<private-key> AUTH_KID=<kid> python -m kfinance.proxy_mcp
The server starts on http://127.0.0.1:8000/mcp by default. Use --host and --port to configure binding.
For full documentation including configuration options, authentication methods, and production considerations, see kfinance/integrations/proxy_mcp/README.md.
Development
Working with Local Package Version
If you need to develop using a local version of the kFinance package in another project that uses poetry for package and dependency management, follow these steps:
-
In your dependent project's
pyproject.toml, replace the kFinance package version specification:# Replace this: # kensho-kfinance = "~2.0.1" # With this: kensho-kfinance = { path = "/absolute/path/to/kfinance", develop = true }The
develop = trueflag ensures that the package always matches your local version without requiring reinstallation after changes. -
Update your project's dependencies:
poetry update # Update poetry.lock with new changes poetry install # Install dependencies with updated configurationIf you encounter the error "your pyproject.toml file has significantly changed", run:
poetry lock # Sync the changes to poetry.lock
Versioning
The kFinance uses semantic versioning (major, minor, patch). To bump the version, add a new entry in CHANGELOG.md. This will generate a new version of the library as part of the release process.
License
Licensed under the Apache 2.0 License. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2025-present Kensho Technologies, LLC. The present date is determined by the timestamp of the most recent commit in the repository.
相關資源

S&P Global Plugin
Plugin标普全球(S&P Global)旗下 Kensho 出品的合作伙伴插件:基于 Capital IQ 数据生成一到两页的公司速览(Word 文档)、财报前瞻,以及行业或公司的并购交易摘要。需要 Capital IQ Pro 或标普 LLM-ready API 订阅,结果需专业人员复核。
anthropics/financial-services41.6k
Finance Toolkit MCP
MCPFinanceToolkit 开源库作者出品的 MCP,用 500 多种公式透明的方法计算财务比率、估值、风险与宏观指标,适合公司对比与尽调初稿。托管版免安装,首次连接时填入 Financial Modeling Prep API Key(免费档仅限美股、近 5 年数据);结果需专业人员复核。
JerBouma/FinanceToolkit5.6k
同花顺金融数据服务
MCP同花顺官方的 A 股数据服务,提供托管 MCP,让 agent 查询 A 股行情、财务报表、估值、涨跌停与龙虎榜;指数板块、公募基金、期货期权另有独立服务,可按同样方式添加。需在官网注册并创建 API Key;不含港美股和分钟级行情,分析结论不构成投资建议。
HiThink-Tech/Financial-API4.7k
Financial Modeling Prep MCP Server
MCP把 Financial Modeling Prep 的 250 多个接口交给 agent:财报、估值与技术指标、内部人和国会议员交易、SEC 文件、财报日历等。需 FMP API Key(有免费额度);可连作者托管的地址,或用 Node.js 25.3 以上版本在本地启动 HTTP 服务,配置需要一定技术基础;结果需专业人员复核。
imbenrabi/Financial-Modeling-Prep-MCP-Server149
Octagon MCP Server
MCPOctagon AI 官方投研 MCP,用自然语言分析 SEC 文件、业绩会纪要、财务指标、股票与加密资产行情和新闻,并提供预测市场研究报告和深度研究代理。需注册免费账号获取 API Key,本机需装 Node.js;研究结论需自行核实,不构成投资建议。
OctagonAI/octagon-mcp-server149
OpenBB Platform CLI
CLIOpenBB 开源投资研究平台的命令行版,在终端查询股票行情、财报、宏观经济等金融数据,可用 Routine 脚本批量自动取数。官方维护,部分数据源需自备 API Key。
OpenBB-finance/OpenBB75.9k