AI Legal Consultation Assistant

AI Legal Consultation Assistant

MCP server for evidence-based Chinese legal consultation. It routes labor law questions to a knowledge base and other queries to public search, returning answers with citations and fallback reasons.

Category
Visit Server

README

AI 法律咨询智能助手

这是一个已接入 Codex Skill/MCP 的证据型法律咨询项目。它复刻了原文心工作流的两层路由:先优化问题并识别劳动法意图,再进入劳动法知识库或公网检索分支;所有回答都保留引用、降级原因和调用追踪信息。网页入口为「法律法规智能查询」,核心工作流可在 Codex / MCP / 脚本中复用。

已复刻的工作流

原工作流节点 本项目实现
查询优化 DeepSeek V4 Flash;失败时使用规范化原问题
意图识别 模型仅输出劳动法“是/否”;失败时使用显式关键词规则并标记降级
嵌套工作流 二次优化知识库查询,检索《劳动法》《劳动合同法》,基于证据回答
公网搜索 调用可配置的 HTTP 搜索接口,基于搜索证据与链接回答
选择器 劳动法进入知识库,其他问题进入公网;知识库异常可配置转公网
输出 answercitationswarningsfallback_reasonstrace_id,兼容 output1/output2

完整节点与异常语义见 docs/workflow-spec.md。产品需求见 docs/PRD.md,接口契约见 .agents/skills/consult-chinese-labor-law/references/workflow-contract.md

启动网站

  1. .env.example 复制为 .env.local
  2. 填写 DEEPSEEK_API_KEY。处理非劳动法问题时,还需填写百度 AI 搜索的 PUBLIC_SEARCH_API_KEY
  3. 安装依赖并启动:
npm install
npm --prefix plugins/ai-legal-consultant/server/node install
npm run dev

打开 http://localhost:3001

LEGAL_WORKFLOW_MODE 支持三种模式:

  • custom:强制使用本项目复刻的 DeepSeek/知识库/公网工作流。
  • wenxin:保留并强制使用原文心 Conversation API。
  • auto:有 DeepSeek Key 时使用新工作流;否则在文心凭据存在时继续使用原接口。

未配置远程知识库时,劳动法分支自动使用项目内两部法律的本地快照。百度搜索 Key 未配置时,非劳动法分支会明确报告配置缺失,不会让模型凭记忆猜测。

在 Codex 中调用

项目级 Skill 位于 .agents/skills/consult-chinese-labor-law。重新打开本项目或开始一个新任务后,可直接说:

$consult-chinese-labor-law 公司拖欠三个月工资,我应该如何维权?

Skill 优先调用 MCP 工具 consult_legal_question;MCP 不可用时,会退回项目内 Node.js 脚本。可分发插件位于 plugins/ai-legal-consultant,本地插件市场清单位于 .agents/plugins/marketplace.json

直接调用函数

Node.js:

import { createWorkflowFromEnv } from "./plugins/ai-legal-consultant/server/node/index.mjs";

const result = await createWorkflowFromEnv().consult("公司拖欠工资怎么办?");
console.log(result.answer, result.citations);

Python:

cd plugins/ai-legal-consultant/server/python
python -m pip install -e .
from legal_workflow import create_workflow_from_env

result = create_workflow_from_env().consult("公司拖欠工资怎么办?")
print(result.answer, result.citations)

配置接口

  • DEEPSEEK_API_KEY:DeepSeek API Key。
  • DEEPSEEK_MODEL:默认 deepseek-v4-flash
  • LEGAL_KB_URL / LEGAL_KB_API_KEY:可选远程知识库 HTTP 适配器。
  • PUBLIC_SEARCH_PROVIDER:本项目固定为 baidu
  • PUBLIC_SEARCH_URL:百度官方接口 https://qianfan.baidubce.com/v2/ai_search/web_summary;不要填写百度网页首页。
  • PUBLIC_SEARCH_API_KEY:百度千帆 AI 搜索 API Key,与 DeepSeek Key 分开。
  • LEGAL_ALLOW_WEB_FALLBACK_ON_KB_ERROR:知识库发生异常时是否转公网;知识库正常但无结果时不会静默改道。

接口契约和请求/响应 JSON 见 工作流契约。不要提交 .env.local 或任何真实密钥。

验证

npm test
npm run lint
cd plugins/ai-legal-consultant/server/python
$env:PYTHONPATH="src"
python -m unittest discover -s tests -v

Node 测试同时覆盖 MCP 真实进程握手和工具调用。回答仅供法律信息参考,不构成正式法律意见。

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured