FinScope MCP Server
Connects to OpenAI-compatible chat completion endpoints (configured through FINSCOPE_API_BASE / FINSCOPE_API_MODEL / FINSCOPE_API_KEY with --mode api) to power the agent's language model, which is restricted to two jobs: extracting profile field patches from explicit user text and generating term answers with verbatim citations from retrieved clauses.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@FinScope MCP ServerUse my confirmed profile to find 3-month products that fit my 12,000 savings goal."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
FinScope:用户画像驱动的金融需求分析 Agent
面向财经业务的金融助手 Agent:确认式跨会话 Memory → MCP 工具链 → 确定性收支计算 → 硬约束过滤与规则排序 → 带来源的条款问答。
把「用户确认的跨会话画像、确定性收支计算、模拟产品约束匹配、带来源的条款检索」串成一条可复现的 Agent 链路:资料先确认再写入,金额由 Decimal 程序计算,产品先过硬约束再排序,条款回答必须逐字回指来源。画像的修改、删除与跨用户隔离全部由业务服务在 SQLite 写事务内控制——模型既不参与数值计算,也不能自行确认资料或指定登录身份。
单机可复现部署,随附完整合成数据集(20 个用户画像 / 9 条模拟产品 / 54 条条款),安装后无需任何外部服务即可跑通全链路。本地 Windows / Python 3.12 通过 100 项测试,20 组独立模拟跨会话序列 20 / 20 通过;跨平台结果以顶部 CI 链接为准。

先看结论
能力 | 实现与口径 |
确认式跨会话 Memory | 资料先落为提议(含基础版本、内容摘要、字段差异与来源),确认时用 |
删除与并发写回阻断 | 删除递增 |
幂等与请求复用 |
|
确定性金额计算 | Decimal 精度 50 位上下文;输入限定非负人民币字符串且 ≤ 2 位小数;达成月数按 |
计算正确性 | 39 项领域用例覆盖单位、精度、边界与非法输入;Alice 使用预计算标签比对(月结余 |
产品匹配与排除解释 | 4 项硬约束(金额区间、锁定期 ≤ 目标期限、流动性、风险标签)先于排序执行,应急目标额外附加「仅立即取用」约束;不匹配项返回具体排除原因并挂载对应来源条款 |
规则排序 |
|
条款检索与版本治理 | 生效日期过滤先于检索;同一 |
引用核验 | 模型答复必须同时通过结构与逐字双重校验: |
MCP 工具链 | 5 个工具( |
服务化与安全 | Starlette ASGI 服务 + 内置网页工作台;登录签发 HMAC 签名 HttpOnly Cookie,请求经同源中间件校验,正文上限 32 KiB;服务默认只监听回环地址 |
工程交付 | Ubuntu / Windows × Python 3.11 / 3.12 CI 矩阵覆盖依赖安装、全部测试、打包数据一致性、wheel 构建与源码目录外安装、 |
自动化测试 | 100 项通过(领域 39 / 记忆与业务 27 / Agent 与模型协议 19 / ASGI 网页 13 / 序列与打包 2),20 / 20 组模拟跨会话序列通过,执行 83 次真实 MCP 调用、0 次模型调用 |
Related MCP server: utopia-mcp
系统架构
flowchart LR
U[网页 / CLI] --> S[服务端可信身份]
S --> P[资料提议]
P -->|版本 + 哈希三方校验| D[(SQLite 已确认画像)]
S --> A[分析编排]
D --> T[MCP 工具网关]
A --> T
T --> C[Decimal 收支计算]
T --> M[硬约束过滤 + 规则排序]
T --> R[生效条款检索]
C --> O[带版本与工具轨迹的结果]
M --> O
R --> O
R --> Q[条款问答与引用核验]分层职责、确认事务、删除语义与工具约束见架构与数据边界。
快速开始
需要 Python 3.11 或 3.12。首次安装会从包索引下载依赖。
Windows PowerShell:
git clone https://github.com/fangyunok/finscope-agent.git
cd finscope-agent
python -m venv .venv
.\.venv\Scripts\python.exe -m pip install -r requirements.lock.txt
.\.venv\Scripts\python.exe -m pip install -e ".[dev]"
.\.venv\Scripts\python.exe -m finscope doctor --mode fixture
.\.venv\Scripts\python.exe -m finscope serve --mode fixtureLinux / macOS:
git clone https://github.com/fangyunok/finscope-agent.git
cd finscope-agent
python3 -m venv .venv
.venv/bin/python -m pip install -r requirements.lock.txt
.venv/bin/python -m pip install -e '.[dev]'
.venv/bin/python -m finscope doctor --mode fixture
.venv/bin/python -m finscope serve --mode fixture访问 http://127.0.0.1:7862 并选择演示用户。登录使用内置演示账号选择器签发 HMAC 会话 Cookie,服务默认只监听回环地址;面向多用户部署时把登录端点替换为外部身份提供方即可,会话校验与业务授权逻辑保持不变。
数据库默认保存到当前工作目录 runs/finscope.sqlite,可用 --db 或进程环境变量 FINSCOPE_DB_PATH 指定路径。种子导入只写入用户目录,不会自动确认任何画像;界面中的示例资料仍需核对后手动确认。
演示与检查
.\.venv\Scripts\python.exe -m finscope demo --db runs/demo.sqlite --mode fixture
.\.venv\Scripts\python.exe -m finscope evaluate --output runs/evaluation.json
.\.venv\Scripts\python.exe -m unittest discover -s tests -v
.\.venv\Scripts\python.exe -m pip check
.\.venv\Scripts\python.exe -m build --wheeldemo 覆盖画像提议与确认、通过 MCP 分析、重建服务实例后读取资料、确认期限变更以及删除验证。evaluate 在独立临时数据库中执行 20 组预先标注的模拟跨会话序列,逐案例记录步骤与标签满足情况,并统计工具调用、模型调用与合成数据标记;退出码非零表示某项验收不满足。
接入 Qwen
.env.example 是配置参考;应用只读取进程环境变量,不会自动加载 .env。密钥与个人数据库请勿提交。
$env:FINSCOPE_QWEN_BASE = "http://127.0.0.1:11435/v1"
$env:FINSCOPE_QWEN_MODEL = "qwen3:4b-instruct"
.\.venv\Scripts\python.exe -m finscope doctor --mode qwen
.\.venv\Scripts\python.exe -m finscope serve --mode qwen地址需包含 /v1。doctor 会检查模型目录与目标模型是否就绪。本地服务可用可选变量 FINSCOPE_QWEN_KEY 提供密钥;其他 OpenAI 兼容服务改用 FINSCOPE_API_BASE / _MODEL / _KEY 并选择 --mode api。
模型只承担两件事:从明确文本中抽取画像字段补丁、依据给定条款生成带引用的回答。确认画像、指定登录身份、改动计算公式、调整排序权重都不在模型可调用范围内——这些能力只存在于服务端接口,而确认接口不作为模型工具暴露。
设计边界
以下是明确的设计取舍,不是待补的缺口:
模型权限被显式收窄。抽取与问答之外的动作一律不通向模型:计算由
calculations.py的 Decimal 运算完成,排序由matching.py的固定规则完成,画像写入必须先经人工确认接口。因此模型输出中的任何数值都不会进入结果。风险偏好只接受显式确认。收藏、排除、点击与聊天语气只作为兴趣信号记录,代码中这些行为与风险字段的更新路径是分开的,互不触发。
产品目录是合成数据。9 条模拟产品与 54 条条款由本仓库维护,不含收益率、不接入任何资金操作。替换
src/finscope/data/catalog.json并保持字段结构,即可迁移到自有条款库。引用核验保证的是可追溯性。逐字校验保证回答片段与被引条款一致、引用 ID 合法,因此结果状态为
pending_review(可进入人工核查)。删除作用于应用数据库。删除会清理该用户的画像、字段来源、历史、提议、反馈与个人运行记录,并递增记忆代次。
更完整的验证范围见项目状态与验证范围,评测口径见评测说明,后续演进见演进路线。
Go 计算侧车
确定性计算与检索热路径(金额校验、现金流目标、产品硬约束匹配与规则打分、条款关键词检索)另有一套语义对等的 Go 实现,位于 go/ 目录,用 math/big.Rat 精确有理数运算与 Python Decimal 语义对齐,通过 go/core/matching_test.go 与 go/core/search_test.go 的黄金对拍测试锁定与 Python oracle 逐字段一致。三个无状态工具(calculate_financial_goal / match_products / search_financial_terms)另以 mark3labs/mcp-go 注册成真正的 stdio MCP Server(go/mcpserver),可被任意 MCP Host 接入。这一层只做纯计算与检索,模型抽取、有状态记忆工具、SQLite 事务与乐观锁仍由 Python 服务负责。详见 Go 计算侧车。
工程资料
文档 | 内容 |
分层、确认事务、删除语义、工具约束 | |
HTTP 与 MCP 接口、请求示例 | |
测试范围、序列标签、复现命令 | |
验证清单、数据规模、复现命令 | |
检索层、编排层、评测层与服务层的后续方向 | |
可核实的项目描述及演示顺序 |
依赖版本锁定在 requirements.lock.txt。CI 覆盖 Ubuntu / Windows 与 Python 3.11 / 3.12,并额外检查 wheel 在源码目录之外安装、demo 执行与启动 HTTP 服务。代码与模拟数据采用 MIT License。
This server cannot be deployed
Maintenance
Related MCP Connectors
Governed data discovery, exact queries, decisions, simulations, and runtime utilities over MCP.
Finance canon lookup plus 30 deterministic formulas, each with a verifiable receipt.
Append-only decisions with provenance, supersession, retrieval, and audited MCP actions.
- memoricOAuthio.memoric
Provenance-first database for teams and agents: every value carries sources, rules and coverage.
Related MCP Servers
- FlicenseNot gradedqualityAmaintenanceProvides read-only access to curated financial domain knowledge and product data with verified provenance, enabling users to search and retrieve trusted financial information.-
- FlicenseNot gradedqualityBmaintenanceEnables agents to query a single-source ontology of types, entities, statements, evidence, and controlled vocabulary, including bitemporal "as of" and "as recorded" fact lookups. Supports writing by letting agents propose candidate statements while keeping approval, review transitions, and authoritative reasoning restricted to approved facts.-
- AlicenseNot gradedqualityBmaintenanceEnables users to trace regulatory rule changes to affected parties and required actions through deterministic safety gates, returning dated action plans and hash-linked evidence records. Supports 12 MCP tools over stdio or streamable HTTP for source comparison, obligation decomposition, scope assessment, planning, and evidence validation across multiple domain packs.MIT
- FlicenseAqualityCmaintenanceEnables read-only, bounded quantitative-research workflows with schema compatibility checking and server capability discovery, without exposing market data or live trading.1-