{"id":14520,"date":"2025-04-18T21:17:43","date_gmt":"2025-04-18T13:17:43","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/14520.html"},"modified":"2025-04-18T21:17:43","modified_gmt":"2025-04-18T13:17:43","slug":"%e9%83%a8%e7%bd%b2mcp%e6%9c%8d%e5%8a%a1%e5%99%a8%e7%a4%ba%e4%be%8b%ef%bc%9aibm-bpm-ecm%e5%a2%9e%e5%8a%a0ai%e5%8a%9f%e8%83%bd","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/14520.html","title":{"rendered":"\u90e8\u7f72MCP\u670d\u52a1\u5668\u793a\u4f8b\uff1aIBM BPM\/ECM\u589e\u52a0AI\u529f\u80fd"},"content":{"rendered":"<h2>\u4e00\u3001MCP Server\u539f\u7406<\/h2>\n<h3>1\u3001MCP \u7684\u8bbe\u8ba1\u521d\u8877\u548c\u67b6\u6784\u8981\u70b9&#xff1a;<\/h3>\n<p>MCP&#xff08;Model Context Protocol&#xff09;\u662f\u7531 Anthropic \u63d0\u51fa\u7684\u4e00\u4e2a\u534f\u8bae&#xff0c;\u4e3b\u8981\u76ee\u7684\u662f\u8ba9 AI \u6a21\u578b\u80fd\u591f\u5b89\u5168\u5730\u8bbf\u95ee\u5916\u90e8\u4e0a\u4e0b\u6587\u6570\u636e&#xff0c;\u800c\u4e0d\u9700\u8981 AI \u6a21\u578b\u76f4\u63a5\u63a5\u89e6\u7528\u6237\u7684\u654f\u611f\u672c\u5730\u7cfb\u7edf\u3002\u5176\u5173\u952e\u76ee\u6807\u662f&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u5c06AI \u6a21\u578b\u8fd0\u884c&#xff08;\u7b2c\u4e09\u65b9AI&#xff09;\u4e0e\u672c\u5730\u6570\u636e\u8bbf\u95ee\u9694\u79bb\u5f00\u6765<\/p>\n<\/li>\n<li>\n<p>\u901a\u8fc7\u4e00\u79cd\u534f\u8bae&#xff0c;\u8ba9 AI \u6a21\u578b\u53ef\u4ee5\u201c\u8bf7\u6c42\u201d\u6570\u636e&#xff0c;\u800c\u4e0d\u662f\u201c\u62e5\u6709\u201d\u6570\u636e\u8bbf\u95ee\u6743\u9650\u00a0<\/p>\n<\/li>\n<\/ul>\n<h3>2\u3001\u6838\u5fc3\u7ec4\u4ef6\u7406\u89e3&#xff1a;<\/h3>\n<table>\n<tr>\u7ec4\u4ef6\u804c\u8d23\u63cf\u8ff0<\/tr>\n<tbody>\n<tr>\n<td>MCP Client&#xff08;\u5ba2\u6237\u7aef&#xff09;<\/td>\n<td>\u901a\u5e38\u8fd0\u884c\u5728\u7b2c\u4e09\u65b9 AI \u5e73\u53f0&#xff08;\u5982 Claude\u3001ChatGPT\u3001LangChain Agent \u7b49&#xff09;\u5185\u90e8&#xff0c;\u7528\u6765\u53d1\u9001\u6570\u636e\u8bbf\u95ee\u8bf7\u6c42<\/td>\n<\/tr>\n<tr>\n<td>MCP Server&#xff08;\u670d\u52a1\u5668&#xff09;<\/td>\n<td>\u901a\u5e38\u8fd0\u884c\u5728\u7528\u6237\u672c\u5730&#xff08;\u6216\u4f01\u4e1a\u5185\u7f51&#xff09;&#xff0c;\u7528\u4e8e\u63a5\u6536\u8bf7\u6c42\u5e76\u8bbf\u95ee\u672c\u5730\u8d44\u6e90&#xff0c;\u5982\u6570\u636e\u5e93\u3001\u6587\u4ef6\u7cfb\u7edf\u3001API \u7b49&#xff0c;\u7136\u540e\u628a\u7ed3\u679c\u8fd4\u56de\u7ed9 MCP \u5ba2\u6237\u7aef<\/td>\n<\/tr>\n<tr>\n<td>\u6a21\u578b\u672c\u4f53&#xff08;\u5982 Claude&#xff09;<\/td>\n<td>\u5e76\u4e0d\u76f4\u63a5\u8bbf\u95ee\u672c\u5730\u8d44\u6e90&#xff0c;\u800c\u662f\u901a\u8fc7 MCP \u5ba2\u6237\u7aef\u8f6c\u53d1\u8bf7\u6c42<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>3\u3001MCP Server \u90e8\u7f72\u5efa\u8bae<\/h3>\n<ul>\n<li>\n<p>\u5e94\u8be5\u90e8\u7f72\u5728\u672c\u5730\u7aef&#xff08;\u672c\u5730\u673a \/ \u5185\u7f51\u670d\u52a1\u5668&#xff09;<\/p>\n<\/li>\n<li>\n<p>\u4e0d\u5e94\u66b4\u9732\u7ed9\u516c\u7f51\u7b2c\u4e09\u65b9 AI<\/p>\n<\/li>\n<li>\n<p>\u53ef\u4ee5\u914d\u7f6e\u8bbf\u95ee\u7b56\u7565\u3001\u8eab\u4efd\u8ba4\u8bc1\u3001\u65e5\u5fd7\u7b49\u529f\u80fd<\/p>\n<\/li>\n<\/ul>\n<h3>4\u3001\u793a\u4f8b\u5e94\u7528\u573a\u666f<\/h3>\n<table>\n<tr>\u573a\u666f\u63cf\u8ff0<\/tr>\n<tbody>\n<tr>\n<td>\u4f01\u4e1a\u77e5\u8bc6\u95ee\u7b54<\/td>\n<td>Claude \u63a5\u5165 MCP&#xff0c;\u8bbf\u95ee\u516c\u53f8\u5185\u7f51\u6587\u6863\u5e93\u751f\u6210\u56de\u7b54<\/td>\n<\/tr>\n<tr>\n<td>\u672c\u5730\u6587\u4ef6\u95ee\u7b54<\/td>\n<td>ChatGPT \u63d2\u4ef6\u901a\u8fc7 MCP \u8bf7\u6c42\u8bfb\u53d6\u672c\u5730 PDF<\/td>\n<\/tr>\n<tr>\n<td>\u672c\u5730\u6570\u636e\u5e93\u5206\u6790<\/td>\n<td>LangChain Agent \u7ecf\u7531 MCP \u8c03\u7528 SQL \u67e5\u8be2\u672c\u5730 MySQL \u6570\u636e<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>5\u3001MCP Server \u672c\u8d28\u662f\u4ec0\u4e48&#xff1f;<\/h3>\n<p>MCP Server \u5176\u5b9e\u5c31\u662f\u4e00\u4e2a\u7b26\u5408 MCP \u534f\u8bae\u89c4\u8303 \u7684 Web Server&#xff0c;\u672c\u8d28\u4e0a\u662f\u4e00\u4e2a\u80fd\u63a5\u6536 JSON \u8bf7\u6c42\u3001\u6309\u9700\u8bbf\u95ee\u672c\u5730\u8d44\u6e90&#xff08;\u6587\u4ef6\u3001\u6570\u636e\u5e93\u3001API \u7b49&#xff09;\u5e76\u8fd4\u56de\u7ed3\u679c\u7684 REST API \u670d\u52a1\u3002<\/p>\n<p>\u5b83\u7684\u7279\u70b9\u662f&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u9075\u5faa MCP \u534f\u8bae\u7684\u8bf7\u6c42\u683c\u5f0f\u548c\u54cd\u5e94\u683c\u5f0f<\/p>\n<\/li>\n<li>\n<p>\u652f\u6301\u8eab\u4efd\u8ba4\u8bc1&#xff08;\u53ef\u9009&#xff09;<\/p>\n<\/li>\n<li>\n<p>\u6267\u884c\u201c\u53d7\u63a7\u201d\u7684\u672c\u5730\u64cd\u4f5c&#xff0c;\u6bd4\u5982\u8bfb\u53d6\u6587\u4ef6\u3001\u641c\u7d22\u6570\u636e\u5e93\u3001\u8c03\u7528\u811a\u672c\u7b49<\/p>\n<\/li>\n<\/ul>\n<h3>6\u3001\u5982\u4f55\u81ea\u5df1\u90e8\u7f72\u672c\u5730 MCP Server&#xff1f;<\/h3>\n<p>\u53ef\u4ee5\u9009\u62e9\u76f4\u63a5\u4f7f\u7528\u5df2\u6709\u9879\u76ee\u90e8\u7f72&#xff0c;\u4e5f\u53ef\u4ee5\u6839\u636e\u9700\u8981\u4ece\u96f6\u6784\u5efa\u3002<\/p>\n<h4>\u65b9\u6848\u4e00&#xff1a;\u5feb\u901f\u90e8\u7f72\u5f00\u6e90\u9879\u76ee<\/h4>\n<p>\u4ee5 robvdl\/mcp-server \u4e3a\u4f8b&#xff1a;<\/p>\n<p># \u514b\u9686\u9879\u76ee<br \/>\ngit clone https:\/\/github.com\/robvdl\/mcp-server.git<br \/>\ncd mcp-server<\/p>\n<p># \u521b\u5efa\u865a\u62df\u73af\u5883\u5e76\u5b89\u88c5\u4f9d\u8d56<br \/>\npython3 -m venv venv<br \/>\nsource venv\/bin\/activate<br \/>\npip install -r requirements.txt<\/p>\n<p># \u542f\u52a8\u670d\u52a1&#xff08;\u9ed8\u8ba4\u5728 localhost:3333&#xff09;<br \/>\npython server.py<\/p>\n<p>\u00a0MCP Server \u4f1a\u76d1\u542c\u8bf7\u6c42&#xff0c;\u6bd4\u5982&#xff1a;<\/p>\n<p>POST http:\/\/localhost:3333\/context\/v1\/query<\/p>\n<p>{<br \/>\n  &#034;input&#034;: &#034;\u8bf7\u8bfb\u53d6 mynotes.txt&#034;,<br \/>\n  &#034;context&#034;: {<br \/>\n    &#034;resources&#034;: [&#034;local:files&#034;],<br \/>\n    &#034;tools&#034;: [&#034;read_file&#034;]<br \/>\n  }<br \/>\n}<\/p>\n<p>\u8fd4\u56de\u7c7b\u4f3c&#xff1a;<\/p>\n<p>{<br \/>\n  &#034;output&#034;: &#034;\u8fd9\u91cc\u662f mynotes.txt \u7684\u5185\u5bb9&#xff1a;&#8230;&#034;<br \/>\n}<\/p>\n<h4>\u65b9\u6848\u4e8c&#xff1a;\u7528 Python FastAPI \u81ea\u5df1\u5199\u4e00\u4e2a\u6700\u5c0f MCP Server<\/h4>\n<p>from fastapi import FastAPI, Request<br \/>\nfrom pydantic import BaseModel<br \/>\nimport os<\/p>\n<p>app &#061; FastAPI()<\/p>\n<p>class QueryRequest(BaseModel):<br \/>\n    input: str<br \/>\n    context: dict<\/p>\n<p>&#064;app.post(&#034;\/context\/v1\/query&#034;)<br \/>\nasync def query(req: QueryRequest):<br \/>\n    if &#034;read_file&#034; in req.context.get(&#034;tools&#034;, []):<br \/>\n        filename &#061; req.input.strip()<br \/>\n        try:<br \/>\n            with open(filename, &#034;r&#034;) as f:<br \/>\n                content &#061; f.read()<br \/>\n            return {&#034;output&#034;: content}<br \/>\n        except Exception as e:<br \/>\n            return {&#034;output&#034;: f&#034;\u8bfb\u53d6\u5931\u8d25: {e}&#034;}<br \/>\n    else:<br \/>\n        return {&#034;output&#034;: &#034;\u672a\u77e5\u5de5\u5177&#034;}<\/p>\n<p>\u8fd0\u884c&#xff1a;<\/p>\n<p>uvicorn mcp_server:app &#8211;host 0.0.0.0 &#8211;port 3333<\/p>\n<p>\u8fd9\u5c31\u6709\u4e86\u4e00\u4e2a\u6700\u7b80\u672c\u5730 MCP Server&#xff0c;\u53ef\u4ee5\u914d\u5408 Claude \/ LangChain \u4f7f\u7528\u3002<\/p>\n<h2>\u4e8c\u3001\u793a\u4f8b&#xff1a;\u4f01\u4e1a\u7ea7 MCP Server \u539f\u578b<\/h2>\n<h3>1\u3001\u76ee\u6807\u8d44\u6e90\u6574\u5408\u6e05\u5355&#xff1a;<\/h3>\n<table>\n<tr>\u672c\u5730\u8d44\u6e90\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>&#x1f4ca; \u672c\u5730\u6570\u636e\u5e93<\/td>\n<td>MySQL \/ PostgreSQL \/ SQLite&#xff0c;\u652f\u6301 SQL \u67e5\u8be2<\/td>\n<\/tr>\n<tr>\n<td>&#x1f4c1; IBM ECM<\/td>\n<td>\u5982 FileNet P8 \/ CM8&#xff0c;\u4f7f\u7528 API \u8bbf\u95ee\u6587\u6863\u5143\u6570\u636e\u548c\u5185\u5bb9<\/td>\n<\/tr>\n<tr>\n<td>&#x1f5c3;\ufe0f NFS \u6587\u4ef6\u7cfb\u7edf<\/td>\n<td>\u901a\u8fc7\u6302\u8f7d\u8def\u5f84\u76f4\u63a5\u8bfb\u53d6\u6587\u4ef6&#xff08;\u652f\u6301 PDF \/ \u6587\u672c \/ Office&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>&#x1f300; IBM BPM<\/td>\n<td>\u901a\u8fc7 REST API \u8c03\u7528\u6d41\u7a0b\u5b9e\u4f8b\u3001\u83b7\u53d6\u4efb\u52a1\u72b6\u6001\u7b49<\/td>\n<\/tr>\n<tr>\n<td>&#x1fa9f; Windows \u5de5\u4f5c\u7ec4\u5171\u4eab\u6587\u4ef6\u5939<\/td>\n<td>\u901a\u8fc7 smbclient \/ smbprotocol \u8bbf\u95ee SMB\/CIFS \u5171\u4eab\u8d44\u6e90<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>1.\u67b6\u6784\u5efa\u8bae<\/h4>\n<p>\u6211\u4eec\u53ef\u4ee5\u6784\u5efa\u5982\u4e0b\u7ed3\u6784\u7684 MCP Server&#xff1a;<\/p>\n<p>Claude \/ LangChain \/ AI Agent<br \/>\n          \u2193<br \/>\n     MCP Client<br \/>\n          \u2193<br \/>\n    &#x1f510; \u672c\u5730 MCP Server<br \/>\n          \u251c\u2500\u2500 &#x1f4ca; db_adapter.py        &#xff08;\u6570\u636e\u5e93\u8bbf\u95ee&#xff09;<br \/>\n          \u251c\u2500\u2500 &#x1f4c1; ecm_adapter.py       &#xff08;IBM ECM&#xff09;<br \/>\n          \u251c\u2500\u2500 &#x1f4c2; nfs_adapter.py       &#xff08;\u672c\u5730\/NFS \u6587\u4ef6\u8bbf\u95ee&#xff09;<br \/>\n          \u251c\u2500\u2500 &#x1f300; bpm_adapter.py       &#xff08;IBM BPM&#xff09;<br \/>\n          \u2514\u2500\u2500 &#x1fa9f; smb_adapter.py       &#xff08;Windows \u6587\u4ef6\u5171\u4eab&#xff09;<\/p>\n<p>\u6bcf\u4e00\u4e2a\u6a21\u5757\u6211\u4eec\u90fd\u7528 Python \u5b9e\u73b0&#xff0c;\u7edf\u4e00\u66b4\u9732 REST \u63a5\u53e3&#xff0c;\u6bd4\u5982 \/context\/v1\/query&#xff0c;\u7136\u540e\u6839\u636e input \u548c context.tools \u5206\u53d1\u5230\u5bf9\u5e94 adapter\u3002<\/p>\n<h4>2.\u90e8\u7f72\u65b9\u5f0f\u5efa\u8bae<\/h4>\n<ul>\n<li>\n<p>\u2705 \u4f7f\u7528 FastAPI \u6784\u5efa\u4e3b\u670d\u52a1&#xff08;\u8f7b\u91cf\u3001\u9ad8\u6027\u80fd&#xff09;<\/p>\n<\/li>\n<li>\n<p>\u2705 \u5404\u6a21\u5757\u89e3\u8026&#xff08;\u6613\u6269\u5c55&#xff09;<\/p>\n<\/li>\n<li>\n<p>\u2705 \u652f\u6301 Docker \u5316\u90e8\u7f72&#xff08;\u53ef\u9009&#xff09;<\/p>\n<\/li>\n<li>\n<p>\u2705 \u652f\u6301\u8eab\u4efd\u8ba4\u8bc1&#xff08;Token \u6216 API \u5bc6\u94a5&#xff09;\u00a0<\/p>\n<\/li>\n<\/ul>\n<h4>3.\u793a\u4f8b\u529f\u80fd\u8c03\u7528<\/h4>\n<h5>\u8bf7\u6c42&#xff1a;<\/h5>\n<p>{<br \/>\n  &#034;input&#034;: &#034;select * from customers where city &#061; &#039;Shanghai&#039;;&#034;,<br \/>\n  &#034;context&#034;: {<br \/>\n    &#034;tools&#034;: [&#034;query_database&#034;],<br \/>\n    &#034;params&#034;: {<br \/>\n      &#034;db_name&#034;: &#034;crm&#034;,<br \/>\n      &#034;db_type&#034;: &#034;mysql&#034;<br \/>\n    }<br \/>\n  }<br \/>\n}<\/p>\n<p>\u00a0\u54cd\u5e94&#xff1a;<\/p>\n<p>{<br \/>\n  &#034;output&#034;: &#034;\u7ed3\u679c&#xff1a;\u5ba2\u6237\u603b\u6570 5&#xff0c;\u5206\u522b\u4e3a&#xff1a;\u5f20\u4e09\u3001\u674e\u56db&#8230;&#034;<br \/>\n}<\/p>\n<h3>2\u3001\u6700\u5c0fMCP Server\u539f\u578b<\/h3>\n<p>\u6700\u5c0f\u53ef\u8fd0\u884c\u7684 MCP Server \u539f\u578b&#xff0c;\u652f\u6301&#xff1a;<\/p>\n<p>\u2705 \u901a\u8fc7 HTTP \u63a5\u53e3\u63a5\u6536 SQL \u67e5\u8be2\u8bf7\u6c42 \u2705 \u6267\u884c\u672c\u5730\u6570\u636e\u5e93&#xff08;\u652f\u6301 SQLite \u6216 MySQL&#xff09;\u67e5\u8be2 \u2705 \u8fd4\u56de\u7ed3\u6784\u5316\u67e5\u8be2\u7ed3\u679c<\/p>\n<h4>\u9879\u76ee\u7ed3\u6784\u8bbe\u8ba1<\/h4>\n<p>mcp_server\/<br \/>\n\u251c\u2500\u2500 main.py              # FastAPI \u4e3b\u670d\u52a1<br \/>\n\u251c\u2500\u2500 db_adapter.py        # \u6570\u636e\u5e93\u8bbf\u95ee\u6a21\u5757<br \/>\n\u251c\u2500\u2500 requirements.txt     # \u4f9d\u8d56\u5217\u8868<br \/>\n\u2514\u2500\u2500 config.py            # \u6570\u636e\u5e93\u8fde\u63a5\u914d\u7f6e<\/p>\n<h4>1. requirements.txt<\/h4>\n<p>fastapi<br \/>\nuvicorn<br \/>\nsqlalchemy<br \/>\npymysql        # \u5982\u679c\u4f7f\u7528 MySQL<\/p>\n<h4>2. config.py&#xff08;\u6570\u636e\u5e93\u8fde\u63a5\u914d\u7f6e&#xff09;<\/h4>\n<p># config.py<br \/>\nDATABASES &#061; {<br \/>\n    &#034;sqlite&#034;: {<br \/>\n        &#034;url&#034;: &#034;sqlite:\/\/\/.\/test.db&#034;<br \/>\n    },<br \/>\n    &#034;mysql&#034;: {<br \/>\n        &#034;url&#034;: &#034;mysql&#043;pymysql:\/\/user:password&#064;localhost:3306\/yourdb&#034;<br \/>\n    }<br \/>\n}<\/p>\n<h4>3. db_adapter.py<\/h4>\n<p># db_adapter.py<br \/>\nfrom sqlalchemy import create_engine, text<br \/>\nfrom config import DATABASES<\/p>\n<p>def run_query(db_type: str, query: str):<br \/>\n    if db_type not in DATABASES:<br \/>\n        return f&#034;\u4e0d\u652f\u6301\u7684\u6570\u636e\u5e93\u7c7b\u578b&#xff1a;{db_type}&#034;<\/p>\n<p>    engine &#061; create_engine(DATABASES[db_type][&#034;url&#034;])<br \/>\n    try:<br \/>\n        with engine.connect() as conn:<br \/>\n            result &#061; conn.execute(text(query))<br \/>\n            rows &#061; [dict(row._mapping) for row in result]<br \/>\n            return rows<br \/>\n    except Exception as e:<br \/>\n        return f&#034;\u67e5\u8be2\u5931\u8d25&#xff1a;{e}&#034;<\/p>\n<h4>4. main.py<\/h4>\n<p># main.py<br \/>\nfrom fastapi import FastAPI, Request<br \/>\nfrom pydantic import BaseModel<br \/>\nfrom db_adapter import run_query<\/p>\n<p>app &#061; FastAPI()<\/p>\n<p>class MCPRequest(BaseModel):<br \/>\n    input: str<br \/>\n    context: dict<\/p>\n<p>&#064;app.post(&#034;\/context\/v1\/query&#034;)<br \/>\nasync def handle_query(req: MCPRequest):<br \/>\n    tools &#061; req.context.get(&#034;tools&#034;, [])<br \/>\n    params &#061; req.context.get(&#034;params&#034;, {})<\/p>\n<p>    if &#034;query_database&#034; in tools:<br \/>\n        db_type &#061; params.get(&#034;db_type&#034;, &#034;sqlite&#034;)<br \/>\n        query &#061; req.input<br \/>\n        result &#061; run_query(db_type, query)<br \/>\n        return {&#034;output&#034;: result}<br \/>\n    else:<br \/>\n        return {&#034;output&#034;: &#034;\u4e0d\u652f\u6301\u7684\u5de5\u5177\u8c03\u7528&#034;}<\/p>\n<h4>5.\u542f\u52a8 MCP Server<\/h4>\n<p>uvicorn main:app &#8211;reload &#8211;port 3333<\/p>\n<p>\u8fd9\u5c31\u6709\u4e86\u4e00\u4e2a\u8fd0\u884c\u5728 http:\/\/localhost:3333\/context\/v1\/query \u7684 MCP Server&#xff0c;\u53ef\u4ee5\u5904\u7406 SQL \u8bf7\u6c42\u4e86\u3002<\/p>\n<h4>6.\u6d4b\u8bd5 POST \u8bf7\u6c42&#xff08;\u7528 Postman \u6216 curl&#xff09;<\/h4>\n<p>curl -X POST http:\/\/localhost:3333\/context\/v1\/query \\\\<br \/>\n -H &#034;Content-Type: application\/json&#034; \\\\<br \/>\n -d &#039;{<br \/>\n   &#034;input&#034;: &#034;SELECT * FROM customers LIMIT 5&#034;,<br \/>\n   &#034;context&#034;: {<br \/>\n     &#034;tools&#034;: [&#034;query_database&#034;],<br \/>\n     &#034;params&#034;: {<br \/>\n       &#034;db_type&#034;: &#034;sqlite&#034;<br \/>\n     }<br \/>\n   }<br \/>\n }&#039;<\/p>\n<h3>3\u3001\u90e8\u7f72MCP Server \u7684 NFS \u6587\u4ef6\u8bbf\u95ee\u6a21\u5757<\/h3>\n<p>\u6784\u5efa MCP Server \u7684 NFS \u6587\u4ef6\u8bbf\u95ee\u6a21\u5757&#xff0c;\u5b83\u5c06\u652f\u6301&#xff1a;<\/p>\n<p>\u2705 \u8bfb\u53d6 NFS \u6302\u8f7d\u76ee\u5f55\u4e2d\u7684\u6587\u4ef6&#xff08;\u6587\u672c\u3001Markdown\u3001PDF\u3001Word \u7b49&#xff09; \u2705 \u901a\u8fc7 MCP \u8bf7\u6c42\u6309\u8def\u5f84\u8bbf\u95ee\u6587\u4ef6\u5185\u5bb9 \u2705 \u8fd4\u56de\u5185\u5bb9\u7247\u6bb5\u7528\u4e8e AI \u7406\u89e3&#xff08;\u53ef\u5206\u9875 \/ \u622a\u65ad&#xff09;<\/p>\n<h4>\u9879\u76ee\u7ed3\u6784\u66f4\u65b0<\/h4>\n<p>mcp_server\/<br \/>\n\u251c\u2500\u2500 main.py              # FastAPI \u4e3b\u670d\u52a1<br \/>\n\u251c\u2500\u2500 db_adapter.py        # \u6570\u636e\u5e93\u8bbf\u95ee\u6a21\u5757<br \/>\n\u251c\u2500\u2500 file_adapter.py      # NFS \u6587\u4ef6\u8bbf\u95ee\u6a21\u5757 \u2705<br \/>\n\u251c\u2500\u2500 requirements.txt<br \/>\n\u251c\u2500\u2500 config.py<\/p>\n<h4>1. \u914d\u7f6e NFS \u8def\u5f84&#xff08;config.py&#xff09;<\/h4>\n<p># config.py<br \/>\nNFS_MOUNT_ROOT &#061; &#034;\/mnt\/nfs_shared&#034;  # \u4f60\u7684 NFS \u6302\u8f7d\u76ee\u5f55&#xff08;\u4f8b\u5982\u901a\u8fc7 \/etc\/fstab \u6216 autofs \u5df2\u6302\u8f7d&#xff09;<\/p>\n<h4>2. \u5b9e\u73b0 file_adapter.py<\/h4>\n<p># file_adapter.py<br \/>\nimport os<br \/>\nfrom config import NFS_MOUNT_ROOT<\/p>\n<p>def read_file_from_nfs(rel_path: str, max_bytes&#061;5000):<br \/>\n    safe_path &#061; os.path.normpath(os.path.join(NFS_MOUNT_ROOT, rel_path))<\/p>\n<p>    # \u9632\u6b62\u8def\u5f84\u9003\u9038\u653b\u51fb<br \/>\n    if not safe_path.startswith(NFS_MOUNT_ROOT):<br \/>\n        return &#034;\u975e\u6cd5\u8def\u5f84&#034;<\/p>\n<p>    if not os.path.exists(safe_path):<br \/>\n        return f&#034;\u6587\u4ef6\u4e0d\u5b58\u5728&#xff1a;{rel_path}&#034;<\/p>\n<p>    try:<br \/>\n        with open(safe_path, &#034;rb&#034;) as f:<br \/>\n            content &#061; f.read(max_bytes)<br \/>\n            try:<br \/>\n                return content.decode(&#034;utf-8&#034;)<br \/>\n            except UnicodeDecodeError:<br \/>\n                return &#034;\u6587\u4ef6\u4e0d\u662f UTF-8 \u7f16\u7801\u6587\u672c&#xff0c;\u65e0\u6cd5\u89e3\u6790&#034;<br \/>\n    except Exception as e:<br \/>\n        return f&#034;\u8bfb\u53d6\u6587\u4ef6\u5931\u8d25&#xff1a;{e}&#034;<\/p>\n<h4>3. \u4fee\u6539 main.py \u652f\u6301 read_nfs_file<\/h4>\n<p># main.py&#xff08;\u65b0\u589e\u90e8\u5206&#xff09;<br \/>\nfrom file_adapter import read_file_from_nfs<\/p>\n<p>&#064;app.post(&#034;\/context\/v1\/query&#034;)<br \/>\nasync def handle_query(req: MCPRequest):<br \/>\n    tools &#061; req.context.get(&#034;tools&#034;, [])<br \/>\n    params &#061; req.context.get(&#034;params&#034;, {})<br \/>\n    query &#061; req.input<\/p>\n<p>    if &#034;query_database&#034; in tools:<br \/>\n        db_type &#061; params.get(&#034;db_type&#034;, &#034;sqlite&#034;)<br \/>\n        result &#061; run_query(db_type, query)<br \/>\n        return {&#034;output&#034;: result}<\/p>\n<p>    elif &#034;read_nfs_file&#034; in tools:<br \/>\n        file_path &#061; query.strip()  # \u4f8b\u5982: &#034;project\/info.md&#034;<br \/>\n        result &#061; read_file_from_nfs(file_path)<br \/>\n        return {&#034;output&#034;: result}<\/p>\n<p>    return {&#034;output&#034;: &#034;\u4e0d\u652f\u6301\u7684\u5de5\u5177\u8c03\u7528&#034;}<\/p>\n<h4>4.\u793a\u4f8b\u8bf7\u6c42&#xff08;curl&#xff09;<\/h4>\n<p>curl -X POST http:\/\/localhost:3333\/context\/v1\/query \\\\<br \/>\n -H &#034;Content-Type: application\/json&#034; \\\\<br \/>\n -d &#039;{<br \/>\n   &#034;input&#034;: &#034;documents\/meeting_notes.txt&#034;,<br \/>\n   &#034;context&#034;: {<br \/>\n     &#034;tools&#034;: [&#034;read_nfs_file&#034;]<br \/>\n   }<br \/>\n }&#039;<\/p>\n<p>\u786e\u4fdd\u5df2\u5c06 documents\/meeting_notes.txt \u653e\u5728 \/mnt\/nfs_shared\/documents\/meeting_notes.txt&#xff0c;\u5373\u53ef\u8bfb\u53d6\u5185\u5bb9\u3002<\/p>\n<h3>4\u3001\u52a0\u5165PDF\u6587\u4ef6\u63d0\u4f9b\u529f\u80fd<\/h3>\n<p>\u52a0\u5165 PDF \u6587\u4ef6\u63d0\u53d6\u529f\u80fd \u662f MCP \u8bfb\u53d6\u4f01\u4e1a\u6587\u6863\u975e\u5e38\u5173\u952e\u7684\u4e00\u6b65\u3002\u6211\u4eec\u5c06&#xff1a;<\/p>\n<p>\u2705 \u5728\u539f\u6765\u7684 read_file_from_nfs \u57fa\u7840\u4e0a\u6269\u5c55 \u2705 \u81ea\u52a8\u5224\u65ad\u6587\u4ef6\u7c7b\u578b&#xff0c;\u5982\u679c\u662f PDF&#xff0c;\u5219\u63d0\u53d6\u6587\u672c\u5185\u5bb9\u8fd4\u56de<\/p>\n<h4>1. \u5b89\u88c5 PDF \u63d0\u53d6\u4f9d\u8d56<\/h4>\n<p>\u4f7f\u7528 pdfplumber&#xff0c;\u5b83\u80fd\u4fdd\u7559 PDF \u4e2d\u7684\u6bb5\u843d\u7ed3\u6784&#xff0c;\u6bd4 PyPDF2 \u66f4\u9002\u5408\u505a\u5185\u5bb9\u7406\u89e3\u3002<\/p>\n<p>pip install pdfplumber<\/p>\n<p>\u53ef\u4ee5\u628a\u5b83\u52a0\u5230 requirements.txt \u91cc&#xff1a;<\/p>\n<p>pdfplumber<\/p>\n<h4>2. \u66f4\u65b0 file_adapter.py<\/h4>\n<p># file_adapter.py<br \/>\nimport os<br \/>\nimport pdfplumber<br \/>\nfrom config import NFS_MOUNT_ROOT<\/p>\n<p>def read_file_from_nfs(rel_path: str, max_chars&#061;5000):<br \/>\n    safe_path &#061; os.path.normpath(os.path.join(NFS_MOUNT_ROOT, rel_path))<\/p>\n<p>    if not safe_path.startswith(NFS_MOUNT_ROOT):<br \/>\n        return &#034;\u975e\u6cd5\u8def\u5f84&#034;<\/p>\n<p>    if not os.path.exists(safe_path):<br \/>\n        return f&#034;\u6587\u4ef6\u4e0d\u5b58\u5728&#xff1a;{rel_path}&#034;<\/p>\n<p>    # \u5224\u65ad\u6587\u4ef6\u7c7b\u578b<br \/>\n    if rel_path.lower().endswith(&#034;.pdf&#034;):<br \/>\n        return extract_pdf_text(safe_path, max_chars)<br \/>\n    else:<br \/>\n        try:<br \/>\n            with open(safe_path, &#034;r&#034;, encoding&#061;&#034;utf-8&#034;) as f:<br \/>\n                return f.read(max_chars)<br \/>\n        except UnicodeDecodeError:<br \/>\n            return &#034;\u6587\u4ef6\u4e0d\u662f UTF-8 \u7f16\u7801\u6587\u672c&#xff0c;\u65e0\u6cd5\u89e3\u6790&#034;<br \/>\n        except Exception as e:<br \/>\n            return f&#034;\u8bfb\u53d6\u5931\u8d25&#xff1a;{e}&#034;<\/p>\n<p>def extract_pdf_text(file_path: str, max_chars&#061;5000):<br \/>\n    try:<br \/>\n        with pdfplumber.open(file_path) as pdf:<br \/>\n            text &#061; &#039;&#039;<br \/>\n            for page in pdf.pages:<br \/>\n                text &#043;&#061; page.extract_text() or &#039;&#039;<br \/>\n                if len(text) &gt;&#061; max_chars:<br \/>\n                    break<br \/>\n        return text[:max_chars] or &#034;PDF \u63d0\u53d6\u5185\u5bb9\u4e3a\u7a7a&#034;<br \/>\n    except Exception as e:<br \/>\n        return f&#034;PDF \u89e3\u6790\u5931\u8d25&#xff1a;{e}&#034;<\/p>\n<h4>3.\u793a\u4f8b&#xff1a;\u8bfb\u53d6 PDF<\/h4>\n<p>curl -X POST http:\/\/localhost:3333\/context\/v1\/query \\\\<br \/>\n -H &#034;Content-Type: application\/json&#034; \\\\<br \/>\n -d &#039;{<br \/>\n   &#034;input&#034;: &#034;reports\/summary_2023.pdf&#034;,<br \/>\n   &#034;context&#034;: {<br \/>\n     &#034;tools&#034;: [&#034;read_nfs_file&#034;]<br \/>\n   }<br \/>\n }&#039;<\/p>\n<p>\u53ea\u8981\u628a summary_2023.pdf \u653e\u5230 \/mnt\/nfs_shared\/reports\/ \u4e0b&#xff0c;\u7cfb\u7edf\u5c31\u4f1a\u81ea\u52a8\u89e3\u6790 PDF \u5e76\u8fd4\u56de\u524d\u82e5\u5e72\u5b57\u7b26\u7684\u6587\u672c\u5185\u5bb9\u3002<\/p>\n<h4>4.\u53ef\u9009\u589e\u5f3a\u529f\u80fd<\/h4>\n<table>\n<tr>\u529f\u80fd\u63cf\u8ff0<\/tr>\n<tbody>\n<tr>\n<td>\u2705 \u9650\u5236\u9875\u9762\u6570<\/td>\n<td>\u53ea\u89e3\u6790\u524d N \u9875&#xff0c;\u63d0\u9ad8\u901f\u5ea6<\/td>\n<\/tr>\n<tr>\n<td>\u2705 \u652f\u6301\u63d0\u53d6\u8868\u683c<\/td>\n<td>\u4f7f\u7528 pdfplumber \u7684 extract_table()<\/td>\n<\/tr>\n<tr>\n<td>\u2705 \u591a\u8bed\u8a00\u652f\u6301<\/td>\n<td>\u57fa\u4e8e\u5185\u5bb9\u505a OCR \u6216\u8bed\u8a00\u6807\u8bc6<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>5\u3001\u00a0IBM BPM \/ ECM \u63a5\u5165\u6a21\u5757<\/h3>\n<p>\u63a5\u4e0b\u6765\u6784\u5efa MCP Server \u7684 IBM BPM &#043; IBM ECM \u63a5\u5165\u6a21\u5757&#xff0c;\u76ee\u6807\u662f&#xff1a;<\/p>\n<p>\u2705 \u901a\u8fc7\u7edf\u4e00\u63a5\u53e3\u8bfb\u53d6 IBM BPM \u6d41\u7a0b\u4fe1\u606f&#xff08;\u6d41\u7a0b\u72b6\u6001\u3001\u5f53\u524d\u8282\u70b9\u3001\u5904\u7406\u4eba\u7b49&#xff09; \u2705 \u901a\u8fc7\u7edf\u4e00\u63a5\u53e3\u8bfb\u53d6 IBM ECM \u6587\u4ef6\u5185\u5bb9 \/ \u5143\u6570\u636e&#xff08;\u5982\u57fa\u4e8e FileNet&#xff09; \u2705 \u5c01\u88c5\u4e3a MCP \u7684\u5de5\u5177\u8c03\u7528\u6a21\u5757&#xff0c;\u4f9b AI \u591a\u667a\u80fd\u4f53\u8bfb\u53d6\u4e1a\u52a1\u72b6\u6001\u3001\u5185\u5bb9\u6750\u6599\u7b49<\/p>\n<h4>1.\u8bbe\u8ba1\u6982\u89c8<\/h4>\n<p>\u6a21\u5757\u6211\u4eec\u5c06\u5206\u4e24\u4e2a\u90e8\u5206&#xff1a;<\/p>\n<table>\n<tr>\u6a21\u5757\u529f\u80fd\u6280\u672f\u65b9\u5f0f<\/tr>\n<tbody>\n<tr>\n<td>bpm_adapter.py<\/td>\n<td>\u67e5\u8be2\u6d41\u7a0b\u72b6\u6001\u3001\u4efb\u52a1\u8282\u70b9\u3001\u5904\u7406\u4eba\u7b49<\/td>\n<td>\u901a\u8fc7 IBM BPM REST API<\/td>\n<\/tr>\n<tr>\n<td>ecm_adapter.py<\/td>\n<td>\u67e5\u8be2\u6587\u4ef6\u5143\u4fe1\u606f\u3001\u9884\u89c8\u6587\u672c\u5185\u5bb9<\/td>\n<td>\u901a\u8fc7 FileNet Content Engine \u6216 IBM CMIS API<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>2.MCP Server \u9879\u76ee\u7ed3\u6784\u66f4\u65b0<\/h4>\n<p>mcp_server\/<br \/>\n\u251c\u2500\u2500 main.py<br \/>\n\u251c\u2500\u2500 config.py<br \/>\n\u251c\u2500\u2500 db_adapter.py<br \/>\n\u251c\u2500\u2500 file_adapter.py<br \/>\n\u251c\u2500\u2500 bpm_adapter.py        \u2705 IBM BPM \u8bbf\u95ee\u6a21\u5757<br \/>\n\u251c\u2500\u2500 ecm_adapter.py        \u2705 IBM ECM \u8bbf\u95ee\u6a21\u5757<br \/>\n\u251c\u2500\u2500 auth.py<br \/>\n\u251c\u2500\u2500 requirements.txt<\/p>\n<h4>3.IBM BPM \u63a5\u5165\u6a21\u5757\u793a\u4f8b&#xff08;bpm_adapter.py&#xff09;<\/h4>\n<p>\u5047\u8bbe BPM \u4f7f\u7528 Business Automation Workflow&#xff0c;\u652f\u6301 REST \u63a5\u53e3<\/p>\n<p># bpm_adapter.py<br \/>\nimport requests<br \/>\nfrom config import BPM_API_BASE, BPM_AUTH<\/p>\n<p>def get_bpm_process_info(process_id: str):<br \/>\n    try:<br \/>\n        url &#061; f&#034;{BPM_API_BASE}\/rest\/bpm\/wle\/v1\/process\/{process_id}&#034;<br \/>\n        headers &#061; {&#034;Authorization&#034;: f&#034;Basic {BPM_AUTH}&#034;}<br \/>\n        resp &#061; requests.get(url, headers&#061;headers, timeout&#061;10)<br \/>\n        data &#061; resp.json()<\/p>\n<p>        if data.get(&#034;status&#034;) !&#061; &#034;200&#034;:<br \/>\n            return f&#034;\u6d41\u7a0b\u67e5\u8be2\u5931\u8d25&#xff1a;{data.get(&#039;statusReason&#039;)}&#034;<\/p>\n<p>        instance &#061; data[&#034;data&#034;][&#034;processInstance&#034;]<br \/>\n        return {<br \/>\n            &#034;\u6d41\u7a0bID&#034;: instance[&#034;piid&#034;],<br \/>\n            &#034;\u72b6\u6001&#034;: instance[&#034;executionState&#034;],<br \/>\n            &#034;\u6d41\u7a0b\u56fe&#034;: instance[&#034;bpdName&#034;],<br \/>\n            &#034;\u5f53\u524d\u73af\u8282&#034;: instance[&#034;activities&#034;]<br \/>\n        }<\/p>\n<p>    except Exception as e:<br \/>\n        return f&#034;\u8fde\u63a5 BPM \u5931\u8d25&#xff1a;{e}&#034;<\/p>\n<h4>4.IBM ECM \u63a5\u5165\u6a21\u5757\u793a\u4f8b&#xff08;ecm_adapter.py&#xff09;<\/h4>\n<p>\u5047\u8bbe ECM \u4f7f\u7528 FileNet P8&#xff0c;\u652f\u6301 REST \u6216 CMIS \u63a5\u53e3<\/p>\n<p># ecm_adapter.py<br \/>\nimport requests<br \/>\nfrom config import ECM_API_BASE, ECM_AUTH<\/p>\n<p>def get_document_metadata(doc_id: str):<br \/>\n    try:<br \/>\n        url &#061; f&#034;{ECM_API_BASE}\/wsi\/FNCEWS40MTOM\/&#034;<br \/>\n        headers &#061; {<br \/>\n            &#034;Authorization&#034;: f&#034;Basic {ECM_AUTH}&#034;,<br \/>\n            &#034;Content-Type&#034;: &#034;application\/soap&#043;xml&#034;<br \/>\n        }<\/p>\n<p>        # \u5b9e\u9645\u8c03\u7528\u4e2d\u8fd9\u91cc\u8981\u5199 SOAP \u8bf7\u6c42\u4f53\u6216 CMIS \u8bf7\u6c42\u4f53&#xff0c;\u8fd9\u91cc\u7b80\u5316&#xff1a;<br \/>\n        # \u7528 CMIS \u7684\u8bdd\u53ef\u76f4\u63a5\u7528 atom\/xml \u8bfb\u53d6<br \/>\n        # \u53ef\u66ff\u6362\u4e3a requests.get(&#8230;)<\/p>\n<p>        # \u793a\u4f8b\u7b80\u5316\u8fd4\u56de<br \/>\n        return {<br \/>\n            &#034;\u6587\u6863ID&#034;: doc_id,<br \/>\n            &#034;\u6587\u4ef6\u540d&#034;: &#034;\u9500\u552e\u5408\u540c.docx&#034;,<br \/>\n            &#034;\u521b\u5efa\u4eba&#034;: &#034;\u5f20\u4e09&#034;,<br \/>\n            &#034;\u521b\u5efa\u65f6\u95f4&#034;: &#034;2024-11-02&#034;,<br \/>\n            &#034;\u6807\u7b7e&#034;: [&#034;\u5408\u540c&#034;, &#034;\u5ba2\u6237A&#034;]<br \/>\n        }<\/p>\n<p>    except Exception as e:<br \/>\n        return f&#034;\u8fde\u63a5 ECM \u5931\u8d25&#xff1a;{e}&#034;<\/p>\n<h4>5. MCP Server \u6269\u5c55\u5de5\u5177\u63a5\u53e3&#xff08;main.py&#xff09;<\/h4>\n<p>from bpm_adapter import get_bpm_process_info<br \/>\nfrom ecm_adapter import get_document_metadata<\/p>\n<p>&#064;app.post(&#034;\/context\/v1\/query&#034;)<br \/>\nasync def handle_query(<br \/>\n    req: MCPRequest,<br \/>\n    request: Request,<br \/>\n    auth: None &#061; Depends(verify_api_key)<br \/>\n):<br \/>\n    tools &#061; req.context.get(&#034;tools&#034;, [])<br \/>\n    query &#061; req.input.strip()<\/p>\n<p>    if &#034;read_nfs_file&#034; in tools:<br \/>\n        return {&#034;output&#034;: read_file_from_nfs(query)}<\/p>\n<p>    elif &#034;query_bpm&#034; in tools:<br \/>\n        return {&#034;output&#034;: get_bpm_process_info(query)}<\/p>\n<p>    elif &#034;query_ecm&#034; in tools:<br \/>\n        return {&#034;output&#034;: get_document_metadata(query)}<\/p>\n<p>    return {&#034;output&#034;: &#034;\u4e0d\u652f\u6301\u7684\u5de5\u5177\u8c03\u7528&#034;}<\/p>\n<h4>\u00a06.\u793a\u4f8b\u8c03\u7528<\/h4>\n<h5>\u67e5\u8be2 BPM \u6d41\u7a0b\u72b6\u6001&#xff1a;<\/h5>\n<p>curl -X POST http:\/\/localhost:3333\/context\/v1\/query \\\\<br \/>\n -H &#034;Content-Type: application\/json&#034; \\\\<br \/>\n -H &#034;x-api-key: abc123xyz&#034; \\\\<br \/>\n -d &#039;{<br \/>\n   &#034;input&#034;: &#034;12345&#034;,<br \/>\n   &#034;context&#034;: {<br \/>\n     &#034;tools&#034;: [&#034;query_bpm&#034;]<br \/>\n   }<br \/>\n }&#039;<\/p>\n<h5>\u67e5\u8be2 ECM \u6587\u6863\u5143\u6570\u636e&#xff1a;<\/h5>\n<p>curl -X POST http:\/\/localhost:3333\/context\/v1\/query \\\\<br \/>\n -H &#034;Content-Type: application\/json&#034; \\\\<br \/>\n -H &#034;x-api-key: abc123xyz&#034; \\\\<br \/>\n -d &#039;{<br \/>\n   &#034;input&#034;: &#034;doc-20240101001&#034;,<br \/>\n   &#034;context&#034;: {<br \/>\n     &#034;tools&#034;: [&#034;query_ecm&#034;]<br \/>\n   }<br \/>\n }&#039;<\/p>\n<h3>7\u3001IBM ECM \u4e2d\u6587\u5168\u6587\u63d0\u53d6\u6a21\u5757<\/h3>\n<p>\u00a0\u5b9e\u73b0 IBM ECM \u4e2d\u6587\u5168\u6587\u63d0\u53d6\u6a21\u5757&#xff0c;\u652f\u6301\u5c06 ECM \u4e2d\u6587\u6587\u6863\u5185\u5bb9\u63d0\u53d6\u51fa\u6765\u4f9b AI \u5206\u6790&#xff0c;\u6bd4\u5982\u7528\u4e8e&#xff1a;<\/p>\n<ul>\n<li>\n<p>&#x1f916; \u591a\u667a\u80fd\u4f53\u57fa\u4e8e\u6587\u6863\u751f\u6210\u62a5\u544a\/\u56de\u7b54\u95ee\u9898<\/p>\n<\/li>\n<li>\n<p>&#x1f50e; LangChain &#043; Claude \u8fdb\u884c\u95ee\u7b54\u5206\u6790<\/p>\n<\/li>\n<li>\n<p>&#x1f4c4; \u5168\u6587\u7d22\u5f15\u7528\u4e8e\u77e5\u8bc6\u5e93\u6784\u5efa\u00a0<\/p>\n<\/li>\n<\/ul>\n<h4>1.\u573a\u666f\u8bf4\u660e<\/h4>\n<p>\u5047\u8bbe\u4f60\u4f7f\u7528\u7684\u662f IBM FileNet P8 \u6216\u517c\u5bb9 ECM \u7cfb\u7edf&#xff0c;\u63d0\u4f9b\u4e86\u5982\u4e0b\u65b9\u5f0f\u8bbf\u95ee\u6587\u4ef6&#xff1a;<\/p>\n<li>\n<p>\u2705 REST \u6216 CMIS \u63a5\u53e3\u53ef\u4e0b\u8f7d\u6587\u6863\u6587\u4ef6&#xff08;PDF\u3001Word \u7b49&#xff09;<\/p>\n<\/li>\n<li>\n<p>\u2705 \u6587\u6863\u4ee5\u6587\u4ef6\u6d41\u5f62\u5f0f\u8fd4\u56de&#xff0c;\u9700\u4fdd\u5b58\/\u89e3\u6790<\/p>\n<\/li>\n<li>\n<p>\u2705 \u4e2d\u6587\u5185\u5bb9\u63d0\u53d6\u9700\u8981&#xff1a;<\/p>\n<ul>\n<li>\n<p>PDF&#xff1a;\u7528 pdfplumber \/ PyMuPDF<\/p>\n<\/li>\n<li>\n<p>Word&#xff1a;\u7528 python-docx<\/p>\n<\/li>\n<li>\n<p>\u56fe\u7247\u6216\u626b\u63cf PDF&#xff1a;\u53ef\u9009 OCR&#xff1a;pytesseract \/ PaddleOCR\u00a0<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<h4>2.\u66f4\u65b0\u9879\u76ee\u7ed3\u6784&#xff08;\u65b0\u589e\u6a21\u5757&#xff09;<\/h4>\n<p>mcp_server\/<br \/>\n\u251c\u2500\u2500 ecm_adapter.py        \u2705 ECM \u4e2d\u6587\u63d0\u53d6\u903b\u8f91<br \/>\n\u251c\u2500\u2500 utils\/<br \/>\n\u2502   \u2514\u2500\u2500 extract_text.py   \u2705 \u6587\u4ef6\u7c7b\u578b\u8bc6\u522b &#043; \u4e2d\u6587\u63d0\u53d6\u5de5\u5177<\/p>\n<h4>3.\u6587\u4ef6\u5185\u5bb9\u63d0\u53d6\u5de5\u5177&#xff08;utils\/extract_text.py&#xff09;<\/h4>\n<p># utils\/extract_text.py<br \/>\nimport os<br \/>\nimport pdfplumber<br \/>\nimport docx<br \/>\nfrom pathlib import Path<\/p>\n<p>def extract_text_from_file(file_path: str) -&gt; str:<br \/>\n    suffix &#061; Path(file_path).suffix.lower()<\/p>\n<p>    if suffix &#061;&#061; &#034;.pdf&#034;:<br \/>\n        return extract_text_from_pdf(file_path)<br \/>\n    elif suffix in [&#034;.doc&#034;, &#034;.docx&#034;]:<br \/>\n        return extract_text_from_docx(file_path)<br \/>\n    else:<br \/>\n        return f&#034;\u6682\u4e0d\u652f\u6301\u7684\u6587\u4ef6\u7c7b\u578b&#xff1a;{suffix}&#034;<\/p>\n<p>def extract_text_from_pdf(path):<br \/>\n    try:<br \/>\n        text &#061; &#034;&#034;<br \/>\n        with pdfplumber.open(path) as pdf:<br \/>\n            for page in pdf.pages:<br \/>\n                text &#043;&#061; page.extract_text() &#043; &#034;\\\\n&#034;<br \/>\n        return text.strip() or &#034;\u672a\u63d0\u53d6\u5230\u6587\u672c&#xff0c;\u53ef\u80fd\u662f\u626b\u63cf\u4ef6&#034;<br \/>\n    except Exception as e:<br \/>\n        return f&#034;PDF \u63d0\u53d6\u5931\u8d25: {e}&#034;<\/p>\n<p>def extract_text_from_docx(path):<br \/>\n    try:<br \/>\n        doc &#061; docx.Document(path)<br \/>\n        return &#034;\\\\n&#034;.join([para.text for para in doc.paragraphs]).strip()<br \/>\n    except Exception as e:<br \/>\n        return f&#034;Word \u63d0\u53d6\u5931\u8d25: {e}&#034;<\/p>\n<h4>4.\u66f4\u65b0 ECM \u63a5\u53e3&#xff08;ecm_adapter.py&#xff09;<\/h4>\n<p># ecm_adapter.py<br \/>\nimport requests<br \/>\nimport tempfile<br \/>\nfrom config import ECM_API_BASE, ECM_AUTH<br \/>\nfrom utils.extract_text import extract_text_from_file<\/p>\n<p>def get_document_content(doc_id: str):<br \/>\n    try:<br \/>\n        # \u6a21\u62df\u4ece ECM \u4e0b\u8f7d\u6587\u4ef6<br \/>\n        url &#061; f&#034;{ECM_API_BASE}\/download\/{doc_id}&#034;<br \/>\n        headers &#061; {&#034;Authorization&#034;: f&#034;Basic {ECM_AUTH}&#034;}<br \/>\n        response &#061; requests.get(url, headers&#061;headers, timeout&#061;10)<\/p>\n<p>        if response.status_code !&#061; 200:<br \/>\n            return f&#034;\u4e0b\u8f7d\u5931\u8d25&#xff1a;{response.status_code}&#034;<\/p>\n<p>        # \u4e34\u65f6\u4fdd\u5b58\u6587\u4ef6<br \/>\n        suffix &#061; get_suffix_from_header(response)<br \/>\n        with tempfile.NamedTemporaryFile(delete&#061;False, suffix&#061;suffix) as tmp:<br \/>\n            tmp.write(response.content)<br \/>\n            tmp_path &#061; tmp.name<\/p>\n<p>        # \u63d0\u53d6\u5185\u5bb9<br \/>\n        return extract_text_from_file(tmp_path)<\/p>\n<p>    except Exception as e:<br \/>\n        return f&#034;\u83b7\u53d6\u6587\u6863\u5931\u8d25&#xff1a;{e}&#034;<\/p>\n<p>def get_suffix_from_header(response):<br \/>\n    ctype &#061; response.headers.get(&#034;Content-Type&#034;, &#034;&#034;)<br \/>\n    if &#034;pdf&#034; in ctype:<br \/>\n        return &#034;.pdf&#034;<br \/>\n    elif &#034;word&#034; in ctype:<br \/>\n        return &#034;.docx&#034;<br \/>\n    else:<br \/>\n        return &#034;.bin&#034;<\/p>\n<h4>5. \u5728 main.py \u6ce8\u518c\u65b0\u5de5\u5177<\/h4>\n<p>from ecm_adapter import get_document_metadata, get_document_content<\/p>\n<p># \u65b0\u5de5\u5177\u63a5\u5165<br \/>\nelif &#034;read_ecm_content&#034; in tools:<br \/>\n    return {&#034;output&#034;: get_document_content(query)}<\/p>\n<h4>6. \u793a\u4f8b\u8c03\u7528&#xff1a;<\/h4>\n<p>curl http:\/\/localhost:3333\/context\/v1\/query \\\\<br \/>\n -H &#034;Content-Type: application\/json&#034; \\\\<br \/>\n -H &#034;x-api-key: abc123xyz&#034; \\\\<br \/>\n -d &#039;{<br \/>\n   &#034;input&#034;: &#034;doc-20240101-\u5408\u540cABC&#034;,<br \/>\n   &#034;context&#034;: {<br \/>\n     &#034;tools&#034;: [&#034;read_ecm_content&#034;]<br \/>\n   }<br \/>\n }&#039;<\/p>\n<h2>8\u3001ECM &#043; BPM \u8054\u52a8\u6a21\u5757\u6784\u5efa<\/h2>\n<p>ECM &#043; BPM \u8054\u52a8\u6a21\u5757\u6784\u5efa&#xff0c;\u8fd9\u662f\u5b9e\u73b0\u667a\u80fd\u5316\u4e1a\u52a1\u6d41\u7a0b\u5206\u6790\u3001\u6587\u6863\u9a71\u52a8\u5ba1\u6279\u3001Agent \u81ea\u52a8\u8f85\u52a9\u51b3\u7b56\u7684\u6838\u5fc3\u80fd\u529b\u3002<\/p>\n<h3>1.\u76ee\u6807\u8bf4\u660e&#xff1a;\u4ec0\u4e48\u662f ECM &#043; BPM \u8054\u52a8&#xff1f;<\/h3>\n<p>\u300c\u6d41\u7a0b &#043; \u6587\u6863\u300d\u8054\u52a8 &#061; \u7ed3\u5408\u6d41\u7a0b\u72b6\u6001\u548c\u7ed1\u5b9a\u6587\u6863&#xff0c;\u6784\u5efa\u5b8c\u6574\u4e1a\u52a1\u4e0a\u4e0b\u6587\u3002<\/p>\n<h3>2.\u793a\u4f8b\u573a\u666f<\/h3>\n<table>\n<tr>\u573a\u666fBPM \u63d0\u4f9bECM \u63d0\u4f9b\u8054\u52a8\u6548\u679c<\/tr>\n<tbody>\n<tr>\n<td>\u5408\u540c\u5ba1\u6279<\/td>\n<td>\u5f53\u524d\u6d41\u7a0b\u72b6\u6001\u3001\u5904\u7406\u4eba\u3001\u8282\u70b9<\/td>\n<td>\u5408\u540c\u539f\u6587\u5185\u5bb9\u3001\u521b\u5efa\u4eba<\/td>\n<td>\u81ea\u52a8\u751f\u6210\u5ba1\u6279\u6458\u8981\u3001\u667a\u80fd\u8f85\u52a9\u51b3\u7b56<\/td>\n<\/tr>\n<tr>\n<td>\u6863\u6848\u5f52\u6863<\/td>\n<td>\u6d41\u7a0b\u5386\u53f2\u3001\u64cd\u4f5c\u8bb0\u5f55<\/td>\n<td>\u5bf9\u5e94\u626b\u63cf\u4ef6<\/td>\n<td>\u6d41\u7a0b &#043; \u6587\u4ef6\u8054\u5408\u751f\u6210\u5f52\u6863\u8bb0\u5f55<\/td>\n<\/tr>\n<tr>\n<td>\u6295\u8bc9\u5904\u7406<\/td>\n<td>\u6295\u8bc9\u6d41\u7a0b\u8fdb\u5ea6<\/td>\n<td>\u6295\u8bc9\u6750\u6599\u3001\u804a\u5929\u8bb0\u5f55<\/td>\n<td>\u591a\u6a21\u6001\u4fe1\u606f\u805a\u5408\u3001AI \u62a5\u544a\u5206\u6790<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>3.\u7cfb\u7edf\u7ed3\u6784\u56fe<\/h3>\n<p>     Claude \/ LangChain Agent<br \/>\n                \u2502<br \/>\n         \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510<br \/>\n         \u2502   MCP Server \u2502<br \/>\n         \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518<br \/>\n                \u2502<br \/>\n \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510<br \/>\n \u2502 BPM\u6a21\u5757    \u2502  ECM\u6a21\u5757     \u2502<br \/>\n \u2502 get_bpm_process_info()    \u2502<br \/>\n \u2502 &#043; get_linked_documents()  \u2502<br \/>\n \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2518<br \/>\n        \u2502              \u2502<br \/>\n   \u83b7\u53d6\u6d41\u7a0b\u4fe1\u606f    \u83b7\u53d6\u6d41\u7a0b\u7ed1\u5b9a\u6587\u6863 \u2192 \u63d0\u53d6\u5168\u6587<\/p>\n<h3>4.BPM \u8fd4\u56de\u7ed1\u5b9a\u6587\u6863 ID<\/h3>\n<p>\u5728 bpm_adapter.py \u4e2d\u6269\u5c55\u51fd\u6570&#xff0c;\u5047\u8bbe\u67d0\u4e9b\u8282\u70b9\u5e26\u6709\u7ed1\u5b9a\u6587\u6863&#xff1a;<\/p>\n<p>def get_bpm_process_info(process_id: str):<br \/>\n    &#8230;<br \/>\n    instance &#061; data[&#034;data&#034;][&#034;processInstance&#034;]<br \/>\n    linked_docs &#061; []<\/p>\n<p>    for act in instance.get(&#034;activities&#034;, []):<br \/>\n        # \u5047\u8bbe\u9644\u52a0\u5c5e\u6027\u4e2d\u5b58\u653e\u6587\u6863 ID<br \/>\n        doc_id &#061; act.get(&#034;attachedDocumentId&#034;)<br \/>\n        if doc_id:<br \/>\n            linked_docs.append(doc_id)<\/p>\n<p>    return {<br \/>\n        &#034;\u6d41\u7a0bID&#034;: instance[&#034;piid&#034;],<br \/>\n        &#034;\u72b6\u6001&#034;: instance[&#034;executionState&#034;],<br \/>\n        &#034;\u6d41\u7a0b\u56fe&#034;: instance[&#034;bpdName&#034;],<br \/>\n        &#034;\u5f53\u524d\u73af\u8282&#034;: instance[&#034;activities&#034;],<br \/>\n        &#034;\u6587\u6863\u5217\u8868&#034;: linked_docs<br \/>\n    }<\/p>\n<h3>5.ECM \u63d0\u4f9b\u5185\u5bb9\u63d0\u53d6<\/h3>\n<p>\u4f7f\u7528\u524d\u9762\u5199\u597d\u7684 get_document_content(doc_id) \u65b9\u6cd5&#xff0c;\u4f9d\u6b21\u63d0\u53d6\u8fd9\u4e9b\u6587\u6863\u3002<\/p>\n<h3>6.\u8054\u52a8\u51fd\u6570&#xff1a;get_bpm_with_documents(process_id)<\/h3>\n<p>\u653e\u5728 mcp_server\/bpm_ecm_combined.py&#xff1a;<\/p>\n<p># bpm_ecm_combined.py<br \/>\nfrom bpm_adapter import get_bpm_process_info<br \/>\nfrom ecm_adapter import get_document_content<\/p>\n<p>def get_bpm_with_documents(process_id: str):<br \/>\n    bpm_info &#061; get_bpm_process_info(process_id)<\/p>\n<p>    if isinstance(bpm_info, str):<br \/>\n        return f&#034;BPM\u67e5\u8be2\u5931\u8d25&#xff1a;{bpm_info}&#034;<\/p>\n<p>    docs &#061; bpm_info.get(&#034;\u6587\u6863\u5217\u8868&#034;, [])<br \/>\n    doc_contents &#061; []<\/p>\n<p>    for doc_id in docs:<br \/>\n        content &#061; get_document_content(doc_id)<br \/>\n        doc_contents.append({<br \/>\n            &#034;\u6587\u6863ID&#034;: doc_id,<br \/>\n            &#034;\u5185\u5bb9&#034;: content[:1000]  # \u9650\u5236\u5185\u5bb9\u957f\u5ea6<br \/>\n        })<\/p>\n<p>    return {<br \/>\n        &#034;\u6d41\u7a0b\u4fe1\u606f&#034;: bpm_info,<br \/>\n        &#034;\u6587\u6863\u5185\u5bb9&#034;: doc_contents<br \/>\n    }<\/p>\n<h3>7.\u5728 main.py \u4e2d\u66b4\u9732\u5de5\u5177\u8c03\u7528\u63a5\u53e3<\/h3>\n<p>from bpm_ecm_combined import get_bpm_with_documents<\/p>\n<p>&#064;app.post(&#034;\/context\/v1\/query&#034;)<br \/>\nasync def handle_query(&#8230;):<br \/>\n    &#8230;<\/p>\n<p>    elif &#034;bpm_with_doc&#034; in tools:<br \/>\n        return {&#034;output&#034;: get_bpm_with_documents(query)}<\/p>\n<h3>8.\u793a\u4f8b\u8c03\u7528\u65b9\u5f0f<\/h3>\n<p>curl -X POST http:\/\/localhost:3333\/context\/v1\/query \\\\<br \/>\n -H &#034;Content-Type: application\/json&#034; \\\\<br \/>\n -H &#034;x-api-key: abc123xyz&#034; \\\\<br \/>\n -d &#039;{<br \/>\n   &#034;input&#034;: &#034;\u6d41\u7a0bID: process-abc-001&#034;,<br \/>\n   &#034;context&#034;: {<br \/>\n     &#034;tools&#034;: [&#034;bpm_with_doc&#034;]<br \/>\n   }<br \/>\n }&#039;<\/p>\n<h2>9\u3001\u81ea\u52a8\u751f\u6210\u3010\u6d41\u7a0b&#043;\u6587\u6863\u3011\u6458\u8981\u5e76\u8fd4\u56de<\/h2>\n<p>\u81ea\u52a8\u751f\u6210\u3010\u6d41\u7a0b &#043; \u6587\u6863\u3011\u6458\u8981\u5e76\u8fd4\u56de\u529f\u80fd&#xff0c;\u8ba9 Claude \/ GPT \u7b49 AI Agent \u5728\u638c\u63e1\u6d41\u7a0b\u72b6\u6001\u548c\u7ed1\u5b9a\u6587\u6863\u5185\u5bb9\u540e&#xff0c;\u751f\u6210\u4e00\u6bb5\u6e05\u6670\u3001\u4e13\u4e1a\u7684\u4e2d\u6587\u6458\u8981\u3002\u8fd9\u662f\u591a\u667a\u80fd\u4f53\u5e94\u7528\u4e2d\u7684\u5173\u952e\u7b2c\u4e00\u6b65&#xff01;&#x1f680;<\/p>\n<h3>1.\u529f\u80fd\u76ee\u6807<\/h3>\n<p>\u7ed9\u5b9a\u4e00\u4e2a\u6d41\u7a0b ID&#xff0c;\u7cfb\u7edf\u81ea\u52a8&#xff1a;<\/p>\n<li>\n<p>\u83b7\u53d6\u6d41\u7a0b\u4fe1\u606f&#xff08;BPM&#xff09;<\/p>\n<\/li>\n<li>\n<p>\u83b7\u53d6\u7ed1\u5b9a\u6587\u6863\u5185\u5bb9&#xff08;ECM&#xff09;<\/p>\n<\/li>\n<li>\n<p>\u62fc\u63a5\u4e0a\u4e0b\u6587&#xff0c;\u8c03\u7528 Claude \/ GPT \u63a5\u53e3\u751f\u6210\u6458\u8981 \u2705 \u6700\u7ec8\u8fd4\u56de\u7ed3\u6784\u5316\u7684\u6458\u8981\u6587\u672c&#xff08;\u53ef\u7528\u4e8e\u5ba1\u6279\u3001\u5f52\u6863\u3001\u5c55\u793a\u7b49&#xff09;<\/p>\n<\/li>\n<h3>2. \u67b6\u6784\u66f4\u65b0&#xff08;\u65b0\u589e AI \u6458\u8981\u6a21\u5757&#xff09;<\/h3>\n<p>mcp_server\/<br \/>\n\u251c\u2500\u2500 bpm_adapter.py<br \/>\n\u251c\u2500\u2500 ecm_adapter.py<br \/>\n\u251c\u2500\u2500 bpm_ecm_combined.py<br \/>\n\u251c\u2500\u2500 summarizer.py           \u2705 \u65b0\u589e&#xff1a;\u81ea\u52a8\u6458\u8981\u6a21\u5757<\/p>\n<h3>3. \u6784\u5efa\u6458\u8981\u751f\u6210\u6a21\u5757&#xff08;summarizer.py&#xff09;<\/h3>\n<p># summarizer.py<br \/>\nimport os<br \/>\nimport openai  # \u4e5f\u53ef\u63a5 Claude API \u6216\u672c\u5730 LLM<\/p>\n<p>openai.api_key &#061; os.getenv(&#034;OPENAI_API_KEY&#034;)<\/p>\n<p>def generate_summary(bpm_info: dict, doc_contents: list) -&gt; str:<br \/>\n    # \u62fc\u63a5\u4e0a\u4e0b\u6587\u5185\u5bb9<br \/>\n    context_text &#061; &#034;\u3010\u6d41\u7a0b\u4fe1\u606f\u3011\\\\n&#034;<br \/>\n    context_text &#043;&#061; f&#034;\u6d41\u7a0b\u540d\u79f0&#xff1a;{bpm_info[&#039;\u6d41\u7a0b\u56fe&#039;]}\\\\n&#034;<br \/>\n    context_text &#043;&#061; f&#034;\u5f53\u524d\u72b6\u6001&#xff1a;{bpm_info[&#039;\u72b6\u6001&#039;]}\\\\n&#034;<br \/>\n    context_text &#043;&#061; &#034;\u6d41\u7a0b\u8282\u70b9&#xff1a;\\\\n&#034;<br \/>\n    for act in bpm_info[&#034;\u5f53\u524d\u73af\u8282&#034;]:<br \/>\n        context_text &#043;&#061; f&#034; &#8211; {act[&#039;name&#039;]}&#xff08;\u72b6\u6001&#xff1a;{act[&#039;state&#039;]}&#xff09;\\\\n&#034;<\/p>\n<p>    context_text &#043;&#061; &#034;\\\\n\u3010\u6587\u6863\u6458\u8981\u3011\\\\n&#034;<br \/>\n    for doc in doc_contents:<br \/>\n        context_text &#043;&#061; f&#034;\\\\n\u6587\u6863 ID&#xff1a;{doc[&#039;\u6587\u6863ID&#039;]}\\\\n&#034;<br \/>\n        context_text &#043;&#061; doc[&#034;\u5185\u5bb9&#034;][:1000] &#043; &#034;\\\\n&#034;  # \u63a7\u5236\u957f\u5ea6<\/p>\n<p>    # \u5b9a\u4e49 Prompt<br \/>\n    prompt &#061; f&#034;&#034;&#034;\u4f60\u662f\u4f01\u4e1a\u6d41\u7a0b\u6587\u6863\u4e13\u5bb6&#xff0c;\u8bf7\u9605\u8bfb\u4e0b\u5217\u4fe1\u606f&#xff0c;\u8f93\u51fa\u4e00\u6bb5\u4e2d\u6587\u6458\u8981&#xff0c;\u8981\u6c42\u91cd\u70b9\u6e05\u6670\u3001\u8868\u8fbe\u7b80\u7ec3&#xff1a;<br \/>\n{context_text}<br \/>\n&#061;&#061;&gt;<br \/>\n\u8bf7\u7528\u4e2d\u6587\u8f93\u51fa\u6458\u8981&#xff1a;&#034;&#034;&#034;<\/p>\n<p>    # \u8c03\u7528 OpenAI API<br \/>\n    try:<br \/>\n        response &#061; openai.ChatCompletion.create(<br \/>\n            model&#061;&#034;gpt-4&#034;,  # \u53ef\u6539\u4e3a gpt-3.5 \/ Claude \/ \u672c\u5730 LLM<br \/>\n            messages&#061;[{&#034;role&#034;: &#034;user&#034;, &#034;content&#034;: prompt}],<br \/>\n            temperature&#061;0.3,<br \/>\n            max_tokens&#061;512,<br \/>\n        )<br \/>\n        return response.choices[0].message.content.strip()<br \/>\n    except Exception as e:<br \/>\n        return f&#034;AI \u751f\u6210\u6458\u8981\u5931\u8d25&#xff1a;{e}&#034;<\/p>\n<h3>4.\u8054\u52a8\u8c03\u7528&#xff08;\u5728 bpm_ecm_combined.py \u4e2d\u5c01\u88c5&#xff09;<\/h3>\n<p># bpm_ecm_combined.py<br \/>\nfrom summarizer import generate_summary<\/p>\n<p>def get_bpm_with_summary(process_id: str):<br \/>\n    bpm_info &#061; get_bpm_process_info(process_id)<br \/>\n    if isinstance(bpm_info, str):<br \/>\n        return f&#034;BPM\u67e5\u8be2\u5931\u8d25&#xff1a;{bpm_info}&#034;<\/p>\n<p>    docs &#061; bpm_info.get(&#034;\u6587\u6863\u5217\u8868&#034;, [])<br \/>\n    doc_contents &#061; []<br \/>\n    for doc_id in docs:<br \/>\n        content &#061; get_document_content(doc_id)<br \/>\n        doc_contents.append({&#034;\u6587\u6863ID&#034;: doc_id, &#034;\u5185\u5bb9&#034;: content})<\/p>\n<p>    summary &#061; generate_summary(bpm_info, doc_contents)<\/p>\n<p>    return {<br \/>\n        &#034;\u6d41\u7a0bID&#034;: process_id,<br \/>\n        &#034;\u6458\u8981&#034;: summary,<br \/>\n        &#034;\u539f\u59cb\u6d41\u7a0b\u4fe1\u606f&#034;: bpm_info,<br \/>\n        &#034;\u6587\u6863\u5185\u5bb9\u9884\u89c8&#034;: [{ &#034;\u6587\u6863ID&#034;: d[&#034;\u6587\u6863ID&#034;], &#034;\u524d\u51e0\u767e\u5b57&#034;: d[&#034;\u5185\u5bb9&#034;][:300] } for d in doc_contents]<br \/>\n    }<\/p>\n<h3>5.API \u63a5\u5165 main.py<\/h3>\n<p>from bpm_ecm_combined import get_bpm_with_summary<\/p>\n<p>elif &#034;bpm_doc_summary&#034; in tools:<br \/>\n    return {&#034;output&#034;: get_bpm_with_summary(query)}<\/p>\n<h3>6.\u6d4b\u8bd5\u8c03\u7528&#xff08;API \u793a\u4f8b&#xff09;<\/h3>\n<p>curl http:\/\/localhost:3333\/context\/v1\/query \\\\<br \/>\n -H &#034;Content-Type: application\/json&#034; \\\\<br \/>\n -H &#034;x-api-key: abc123xyz&#034; \\\\<br \/>\n -d &#039;{<br \/>\n   &#034;input&#034;: &#034;process-20240318-A\u5408\u540c\u5ba1\u6279&#034;,<br \/>\n   &#034;context&#034;: {<br \/>\n     &#034;tools&#034;: [&#034;bpm_doc_summary&#034;]<br \/>\n   }<br \/>\n }&#039;<\/p>\n<h3>7.\u8fd4\u56de\u793a\u4f8b\u7ed3\u6784<\/h3>\n<p>{<br \/>\n  &#034;\u6d41\u7a0bID&#034;: &#034;process-20240318-A\u5408\u540c\u5ba1\u6279&#034;,<br \/>\n  &#034;\u6458\u8981&#034;: &#034;\u672c\u6d41\u7a0b\u4e3aA\u516c\u53f8\u4e0eB\u516c\u53f8\u91c7\u8d2d\u5408\u540c\u5ba1\u6279\u6d41\u7a0b&#xff0c;\u5f53\u524d\u7531\u6cd5\u52a1\u90e8\u8fdb\u884c\u5ba1\u9605\u3002\u5408\u540c\u6587\u672c\u5df2\u7531\u9500\u552e\u90e8\u4e0a\u4f20&#xff0c;\u5185\u5bb9\u6d89\u53ca\u5e74\u6846\u534f\u8bae\u53ca\u4ed8\u6b3e\u6761\u6b3e\u3002\u9700\u91cd\u70b9\u5173\u6ce8\u4ed8\u6b3e\u5468\u671f\u4e0e\u8fdd\u7ea6\u8d23\u4efb\u3002&#034;,<br \/>\n  &#034;\u539f\u59cb\u6d41\u7a0b\u4fe1\u606f&#034;: {&#8230;},<br \/>\n  &#034;\u6587\u6863\u5185\u5bb9\u9884\u89c8&#034;: [<br \/>\n    { &#034;\u6587\u6863ID&#034;: &#034;doc-abc&#034;, &#034;\u524d\u51e0\u767e\u5b57&#034;: &#034;\u5408\u540c\u7f16\u53f7&#xff1a;2024-A001&#8230;&#034; }<br \/>\n  ]<br \/>\n}<\/p>\n<h2>10\u3001\u81ea\u52a8\u7ed9\u51fa\u5ba1\u6279\u5efa\u8bae<\/h2>\n<p>\u8ba9 Claude \/ GPT \u57fa\u4e8e\u6d41\u7a0b\u548c\u6587\u6863\u5185\u5bb9&#xff0c;\u81ea\u52a8\u7ed9\u51fa\u5ba1\u6279\u5efa\u8bae&#xff0c;\u6bd4\u5982&#xff1a;<\/p>\n<p>\u2705\u300c\u5efa\u8bae\u901a\u8fc7\u5ba1\u6279&#xff0c;\u7406\u7531\u662f\u2026\u2026\u300d \u274c\u300c\u5efa\u8bae\u9000\u56de&#xff0c;\u56e0\u6587\u6863\u7f3a\u5c11\u2026\u2026\u300d &#x1f7e1;\u300c\u9700\u8865\u5145\u8bf4\u660e\u2026\u2026\u300d<\/p>\n<p>\u8fd9\u5c31\u8ba9 AI \u771f\u6b63\u53c2\u4e0e\u5230\u4e1a\u52a1\u5224\u65ad\u4e2d&#xff0c;\u5e2e\u52a9\u7528\u6237\u52a0\u5feb\u6d41\u7a0b\u3001\u63d0\u5347\u51b3\u7b56\u8d28\u91cf\u3002\u4e0b\u9762\u662f\u5b9e\u73b0\u65b9\u5f0f&#x1f447;<\/p>\n<h3>1.\u76ee\u6807\u529f\u80fd&#xff1a;\u81ea\u52a8\u7ed9\u51fa\u5ba1\u6279\u5efa\u8bae<\/h3>\n<ul>\n<li>\n<p>\u8f93\u5165&#xff1a;\u6d41\u7a0b ID<\/p>\n<\/li>\n<li>\n<p>\u7cfb\u7edf\u81ea\u52a8\u83b7\u53d6\u6d41\u7a0b\u4fe1\u606f &#043; \u6587\u6863\u5185\u5bb9<\/p>\n<\/li>\n<li>\n<p>AI \u8f93\u51fa&#xff1a;<\/p>\n<li>\n<p>\u662f\u5426\u5efa\u8bae\u901a\u8fc7&#xff08;\u901a\u8fc7 \/ \u4e0d\u901a\u8fc7 \/ \u9700\u8865\u5145&#xff09;<\/p>\n<\/li>\n<li>\n<p>\u5efa\u8bae\u7406\u7531&#xff08;\u5f15\u7528\u6587\u6863\u3001\u6d41\u7a0b\u7b49&#xff09;\u00a0<\/p>\n<\/li>\n<\/li>\n<\/ul>\n<h3>2.\u6a21\u5757\u7ed3\u6784\u66f4\u65b0<\/h3>\n<p>mcp_server\/<br \/>\n\u251c\u2500\u2500 bpm_adapter.py<br \/>\n\u251c\u2500\u2500 ecm_adapter.py<br \/>\n\u251c\u2500\u2500 summarizer.py<br \/>\n\u251c\u2500\u2500 approval_advisor.py    \u2705 \u65b0\u589e&#xff1a;\u5ba1\u6279\u5efa\u8bae\u6a21\u5757<br \/>\n\u251c\u2500\u2500 bpm_ecm_combined.py<\/p>\n<h3>3.\u6784\u5efa approval_advisor.py\u00a0<\/h3>\n<p># approval_advisor.py<br \/>\nimport os<br \/>\nimport openai<\/p>\n<p>openai.api_key &#061; os.getenv(&#034;OPENAI_API_KEY&#034;)<\/p>\n<p>def generate_approval_advice(bpm_info: dict, doc_contents: list) -&gt; str:<br \/>\n    context &#061; &#034;\u3010\u6d41\u7a0b\u4fe1\u606f\u3011\\\\n&#034;<br \/>\n    context &#043;&#061; f&#034;\u6d41\u7a0b\u540d\u79f0&#xff1a;{bpm_info[&#039;\u6d41\u7a0b\u56fe&#039;]}\\\\n\u5f53\u524d\u72b6\u6001&#xff1a;{bpm_info[&#039;\u72b6\u6001&#039;]}\\\\n&#034;<br \/>\n    context &#043;&#061; &#034;\u6d41\u7a0b\u8282\u70b9&#xff1a;\\\\n&#034;<br \/>\n    for act in bpm_info[&#034;\u5f53\u524d\u73af\u8282&#034;]:<br \/>\n        context &#043;&#061; f&#034; &#8211; {act[&#039;name&#039;]}&#xff08;\u72b6\u6001&#xff1a;{act[&#039;state&#039;]}&#xff09;\\\\n&#034;<\/p>\n<p>    context &#043;&#061; &#034;\\\\n\u3010\u6587\u6863\u5185\u5bb9\u63d0\u8981\u3011\\\\n&#034;<br \/>\n    for doc in doc_contents:<br \/>\n        context &#043;&#061; f&#034;\\\\n\u6587\u6863ID&#xff1a;{doc[&#039;\u6587\u6863ID&#039;]}\\\\n&#034;<br \/>\n        context &#043;&#061; doc[&#034;\u5185\u5bb9&#034;][:1000] &#043; &#034;\\\\n&#034;<\/p>\n<p>    prompt &#061; f&#034;&#034;&#034;\u4f60\u662f\u4f01\u4e1a\u6d41\u7a0b\u5ba1\u6279\u4e13\u5bb6&#xff0c;\u8bf7\u6839\u636e\u4ee5\u4e0b\u4fe1\u606f&#xff0c;\u5224\u65ad\u8be5\u6d41\u7a0b\u662f\u5426\u53ef\u4ee5\u5ba1\u6279\u901a\u8fc7\u3002\u8bf7\u4e25\u683c\u8bc4\u4f30&#xff0c;\u5e76\u8f93\u51fa\u5982\u4e0b\u7ed3\u6784&#xff1a;<\/p>\n<p>1. \u662f\u5426\u5efa\u8bae\u901a\u8fc7\u5ba1\u6279&#xff08;\u901a\u8fc7 \/ \u4e0d\u901a\u8fc7 \/ \u9700\u8865\u5145&#xff09;<br \/>\n2. \u5efa\u8bae\u7406\u7531&#xff08;\u7ed3\u5408\u6d41\u7a0b\u4fe1\u606f\u4e0e\u6587\u6863\u5185\u5bb9&#xff0c;\u7b80\u660e\u6e05\u6670&#xff09;  <\/p>\n<p>\u4ee5\u4e0b\u662f\u4fe1\u606f\u5185\u5bb9&#xff1a;<br \/>\n{context}<br \/>\n&#061;&#061;&gt;<br \/>\n\u8bf7\u8f93\u51fa\u5ba1\u6279\u5efa\u8bae&#xff1a;&#034;&#034;&#034;<\/p>\n<p>    try:<br \/>\n        response &#061; openai.ChatCompletion.create(<br \/>\n            model&#061;&#034;gpt-4&#034;,<br \/>\n            messages&#061;[{&#034;role&#034;: &#034;user&#034;, &#034;content&#034;: prompt}],<br \/>\n            temperature&#061;0.3,<br \/>\n            max_tokens&#061;512,<br \/>\n        )<br \/>\n        return response.choices[0].message.content.strip()<br \/>\n    except Exception as e:<br \/>\n        return f&#034;AI \u751f\u6210\u5ba1\u6279\u5efa\u8bae\u5931\u8d25&#xff1a;{e}&#034;<\/p>\n<h3>4.\u5c01\u88c5\u51fd\u6570 get_bpm_with_advice<\/h3>\n<p>\u66f4\u65b0 bpm_ecm_combined.py&#xff1a;<\/p>\n<p>from approval_advisor import generate_approval_advice<\/p>\n<p>def get_bpm_with_advice(process_id: str):<br \/>\n    bpm_info &#061; get_bpm_process_info(process_id)<br \/>\n    if isinstance(bpm_info, str):<br \/>\n        return f&#034;BPM\u67e5\u8be2\u5931\u8d25&#xff1a;{bpm_info}&#034;<\/p>\n<p>    docs &#061; bpm_info.get(&#034;\u6587\u6863\u5217\u8868&#034;, [])<br \/>\n    doc_contents &#061; []<br \/>\n    for doc_id in docs:<br \/>\n        content &#061; get_document_content(doc_id)<br \/>\n        doc_contents.append({&#034;\u6587\u6863ID&#034;: doc_id, &#034;\u5185\u5bb9&#034;: content})<\/p>\n<p>    advice &#061; generate_approval_advice(bpm_info, doc_contents)<\/p>\n<p>    return {<br \/>\n        &#034;\u6d41\u7a0bID&#034;: process_id,<br \/>\n        &#034;AI\u5ba1\u6279\u5efa\u8bae&#034;: advice,<br \/>\n        &#034;\u539f\u59cb\u6d41\u7a0b\u4fe1\u606f&#034;: bpm_info,<br \/>\n        &#034;\u6587\u6863\u9884\u89c8&#034;: [{ &#034;\u6587\u6863ID&#034;: d[&#034;\u6587\u6863ID&#034;], &#034;\u524d\u51e0\u767e\u5b57&#034;: d[&#034;\u5185\u5bb9&#034;][:300] } for d in doc_contents]<br \/>\n    }<\/p>\n<h3>5.\u5728 main.py \u4e2d\u66b4\u9732 API<\/h3>\n<p>from bpm_ecm_combined import get_bpm_with_advice<\/p>\n<p>elif &#034;bpm_doc_advice&#034; in tools:<br \/>\n    return {&#034;output&#034;: get_bpm_with_advice(query)}<\/p>\n<h3>6.\u6d4b\u8bd5\u8c03\u7528&#xff08;API \u793a\u4f8b&#xff09;<\/h3>\n<p>curl http:\/\/localhost:3333\/context\/v1\/query \\\\<br \/>\n -H &#034;Content-Type: application\/json&#034; \\\\<br \/>\n -H &#034;x-api-key: abc123xyz&#034; \\\\<br \/>\n -d &#039;{<br \/>\n   &#034;input&#034;: &#034;process-20240318-A\u5408\u540c\u5ba1\u6279&#034;,<br \/>\n   &#034;context&#034;: {<br \/>\n     &#034;tools&#034;: [&#034;bpm_doc_advice&#034;]<br \/>\n   }<br \/>\n }&#039;<\/p>\n<h3>7.\u8fd4\u56de\u7ed3\u6784\u793a\u4f8b<\/h3>\n<p>{<br \/>\n  &#034;\u6d41\u7a0bID&#034;: &#034;process-20240318-A\u5408\u540c\u5ba1\u6279&#034;,<br \/>\n  &#034;AI\u5ba1\u6279\u5efa\u8bae&#034;: &#034;1. \u5efa\u8bae\u901a\u8fc7\u5ba1\u6279\\\\n2. \u7406\u7531&#xff1a;\u6d41\u7a0b\u5df2\u5b8c\u6210\u5173\u952e\u8282\u70b9\u5ba1\u6838&#xff0c;\u4e14\u6587\u6863\u4e2d\u5df2\u660e\u786e\u4ed8\u6b3e\u6761\u6b3e\u3001\u8fdd\u7ea6\u8d23\u4efb&#xff0c;\u65e0\u660e\u663e\u9057\u6f0f\u3002&#034;,<br \/>\n  &#034;\u539f\u59cb\u6d41\u7a0b\u4fe1\u606f&#034;: { &#8230; },<br \/>\n  &#034;\u6587\u6863\u9884\u89c8&#034;: [<br \/>\n    { &#034;\u6587\u6863ID&#034;: &#034;doc-abc&#034;, &#034;\u524d\u51e0\u767e\u5b57&#034;: &#034;\u5408\u540c\u7f16\u53f7&#xff1a;2024-A001&#8230;&#034; }<br \/>\n  ]<br \/>\n}<\/p>\n<h2>11\u3001\u589e\u52a0\u6cd5\u52a1Agent&#xff0c;\u4e13\u95e8\u5206\u6790\u5408\u540c\u6761\u6b3e\u7684\u6cd5\u5f8b\u98ce\u9669\u00a0<\/h2>\n<p>\u00a0\u6cd5\u52a1 Agent&#xff0c;\u8ba9\u5b83\u4e13\u6ce8\u5206\u6790\u5408\u540c\u6761\u6b3e\u7684\u6cd5\u5f8b\u98ce\u9669\u3001\u5408\u89c4\u6027\u95ee\u9898\u548c\u5173\u952e\u6ce8\u610f\u4e8b\u9879&#xff0c;\u4ee5 AI \u6cd5\u5f8b\u987e\u95ee\u7684\u8eab\u4efd\u63d0\u4f9b\u4e13\u4e1a\u5224\u65ad&#xff0c;\u8f85\u52a9\u4e1a\u52a1\u5ba1\u6279\u6d41\u7a0b\u3002<\/p>\n<h3>1.\u6cd5\u52a1 Agent \u529f\u80fd\u5b9a\u4f4d<\/h3>\n<table>\n<tr>\u529f\u80fd\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>&#x1f3af; \u805a\u7126\u5206\u6790<\/td>\n<td>\u53ea\u5206\u6790\u5408\u540c\u4e2d\u7684\u6cd5\u5f8b\u6761\u6b3e\u5185\u5bb9<\/td>\n<\/tr>\n<tr>\n<td>&#x1f6e1;\ufe0f \u98ce\u9669\u8bc6\u522b<\/td>\n<td>\u8bc6\u522b\u5982\u8fdd\u7ea6\u8d23\u4efb\u6a21\u7cca\u3001\u4ed8\u6b3e\u65b9\u5f0f\u4e0d\u5408\u89c4\u3001\u7f3a\u5c11\u4e89\u8bae\u89e3\u51b3\u6761\u6b3e\u7b49\u95ee\u9898<\/td>\n<\/tr>\n<tr>\n<td>\u2696\ufe0f \u5408\u89c4\u5efa\u8bae<\/td>\n<td>\u7ed9\u51fa\u4fee\u6b63\u5efa\u8bae\u6216\u6807\u6ce8\u7f3a\u5931\u9879<\/td>\n<\/tr>\n<tr>\n<td>\u2705 \u8f93\u51fa\u683c\u5f0f<\/td>\n<td>\u98ce\u9669\u7b49\u7ea7&#xff08;\u9ad8\/\u4e2d\/\u4f4e&#xff09;&#043; \u95ee\u9898\u6458\u8981 &#043; \u4fee\u6539\u5efa\u8bae<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>2.\u67b6\u6784\u66f4\u65b0<\/h3>\n<p>mcp_server\/<br \/>\n\u251c\u2500\u2500 bpm_adapter.py<br \/>\n\u251c\u2500\u2500 ecm_adapter.py<br \/>\n\u251c\u2500\u2500 approval_advisor.py<br \/>\n\u251c\u2500\u2500 summarizer.py<br \/>\n\u251c\u2500\u2500 legal_advisor.py       \u2705 \u65b0\u589e&#xff1a;\u6cd5\u52a1 Agent \u6a21\u5757<br \/>\n\u251c\u2500\u2500 bpm_ecm_combined.py<\/p>\n<h3>3.\u65b0\u589e legal_advisor.py<\/h3>\n<p># legal_advisor.py<br \/>\nimport os<br \/>\nimport openai<\/p>\n<p>openai.api_key &#061; os.getenv(&#034;OPENAI_API_KEY&#034;)<\/p>\n<p>def analyze_legal_risks(doc_text: str) -&gt; str:<br \/>\n    prompt &#061; f&#034;&#034;&#034;<br \/>\n\u4f60\u662f\u4f01\u4e1a\u5408\u540c\u6cd5\u52a1\u4e13\u5bb6&#xff0c;\u8bf7\u4f60\u9605\u8bfb\u4ee5\u4e0b\u5408\u540c\u6761\u6b3e\u5185\u5bb9&#xff0c;\u4ece\u6cd5\u5f8b\u5408\u89c4\u89d2\u5ea6\u8fdb\u884c\u98ce\u9669\u5206\u6790\u3002\u8bf7\u8bc6\u522b\u4ee5\u4e0b\u95ee\u9898\u5e76\u7ed9\u51fa\u5efa\u8bae&#xff1a;<br \/>\n&#8211; \u662f\u5426\u7f3a\u5c11\u5173\u952e\u6cd5\u5f8b\u6761\u6b3e&#xff08;\u5982\u8fdd\u7ea6\u8d23\u4efb\u3001\u4e89\u8bae\u89e3\u51b3\u3001\u9002\u7528\u6cd5\u5f8b&#xff09;<br \/>\n&#8211; \u662f\u5426\u5b58\u5728\u6a21\u7cca\u3001\u98ce\u9669\u6027\u63cf\u8ff0<br \/>\n&#8211; \u662f\u5426\u6761\u6b3e\u4e4b\u95f4\u5b58\u5728\u51b2\u7a81\u6216\u9057\u6f0f<\/p>\n<p>\u8bf7\u6309\u5982\u4e0b\u7ed3\u6784\u8f93\u51fa&#xff1a;<br \/>\n1. \u98ce\u9669\u7b49\u7ea7&#xff08;\u9ad8 \/ \u4e2d \/ \u4f4e&#xff09;<br \/>\n2. \u98ce\u9669\u8981\u70b9&#xff08;\u5217\u4e3e\u5b58\u5728\u7684\u95ee\u9898&#xff09;<br \/>\n3. \u4fee\u6539\u5efa\u8bae<\/p>\n<p>\u5408\u540c\u5185\u5bb9\u5982\u4e0b&#xff1a;<br \/>\n{doc_text[:3000]}  # \u63a7\u5236\u4e0a\u4e0b\u6587\u957f\u5ea6<br \/>\n&#034;&#034;&#034;<\/p>\n<p>    try:<br \/>\n        response &#061; openai.ChatCompletion.create(<br \/>\n            model&#061;&#034;gpt-4&#034;,<br \/>\n            messages&#061;[{&#034;role&#034;: &#034;user&#034;, &#034;content&#034;: prompt}],<br \/>\n            temperature&#061;0.2,<br \/>\n            max_tokens&#061;512,<br \/>\n        )<br \/>\n        return response.choices[0].message.content.strip()<br \/>\n    except Exception as e:<br \/>\n        return f&#034;\u6cd5\u52a1\u98ce\u9669\u5206\u6790\u5931\u8d25&#xff1a;{e}&#034;<\/p>\n<h3>4.\u7ec4\u5408\u8c03\u7528&#xff08;\u66f4\u65b0 bpm_ecm_combined.py&#xff09;<\/h3>\n<p>from legal_advisor import analyze_legal_risks<\/p>\n<p>def get_bpm_with_legal_advice(process_id: str):<br \/>\n    bpm_info &#061; get_bpm_process_info(process_id)<br \/>\n    if isinstance(bpm_info, str):<br \/>\n        return f&#034;BPM\u67e5\u8be2\u5931\u8d25&#xff1a;{bpm_info}&#034;<\/p>\n<p>    docs &#061; bpm_info.get(&#034;\u6587\u6863\u5217\u8868&#034;, [])<br \/>\n    doc_contents &#061; []<br \/>\n    for doc_id in docs:<br \/>\n        content &#061; get_document_content(doc_id)<br \/>\n        doc_contents.append({&#034;\u6587\u6863ID&#034;: doc_id, &#034;\u5185\u5bb9&#034;: content})<\/p>\n<p>    legal_reports &#061; []<br \/>\n    for doc in doc_contents:<br \/>\n        if &#034;\u5408\u540c&#034; in doc[&#034;\u6587\u6863ID&#034;] or &#034;agreement&#034; in doc[&#034;\u6587\u6863ID&#034;].lower():  # \u7b80\u5355\u5224\u65ad\u662f\u5426\u4e3a\u5408\u540c<br \/>\n            report &#061; analyze_legal_risks(doc[&#034;\u5185\u5bb9&#034;])<br \/>\n            legal_reports.append({<br \/>\n                &#034;\u6587\u6863ID&#034;: doc[&#034;\u6587\u6863ID&#034;],<br \/>\n                &#034;\u6cd5\u5f8b\u98ce\u9669\u5206\u6790&#034;: report<br \/>\n            })<\/p>\n<p>    return {<br \/>\n        &#034;\u6d41\u7a0bID&#034;: process_id,<br \/>\n        &#034;\u6cd5\u5f8b\u98ce\u9669\u62a5\u544a&#034;: legal_reports,<br \/>\n        &#034;\u6587\u6863\u9884\u89c8&#034;: [{ &#034;\u6587\u6863ID&#034;: d[&#034;\u6587\u6863ID&#034;], &#034;\u524d\u51e0\u767e\u5b57&#034;: d[&#034;\u5185\u5bb9&#034;][:300] } for d in doc_contents]<br \/>\n    }<\/p>\n<h3>5. API \u63a5\u5165&#xff08;main.py&#xff09;<\/h3>\n<p>from bpm_ecm_combined import get_bpm_with_legal_advice<\/p>\n<p>elif &#034;legal_risk_analysis&#034; in tools:<br \/>\n    return {&#034;output&#034;: get_bpm_with_legal_advice(query)}<\/p>\n<h3>6.\u6d4b\u8bd5\u8c03\u7528\u793a\u4f8b<\/h3>\n<p>curl http:\/\/localhost:3333\/context\/v1\/query \\\\<br \/>\n -H &#034;Content-Type: application\/json&#034; \\\\<br \/>\n -H &#034;x-api-key: abc123xyz&#034; \\\\<br \/>\n -d &#039;{<br \/>\n   &#034;input&#034;: &#034;process-20240318-A\u5408\u540c\u5ba1\u6279&#034;,<br \/>\n   &#034;context&#034;: {<br \/>\n     &#034;tools&#034;: [&#034;legal_risk_analysis&#034;]<br \/>\n   }<br \/>\n }&#039;<\/p>\n<h3>7.\u8fd4\u56de\u7ed3\u6784\u793a\u4f8b<\/h3>\n<p>{<br \/>\n  &#034;\u6d41\u7a0bID&#034;: &#034;process-20240318-A\u5408\u540c\u5ba1\u6279&#034;,<br \/>\n  &#034;\u6cd5\u5f8b\u98ce\u9669\u62a5\u544a&#034;: [<br \/>\n    {<br \/>\n      &#034;\u6587\u6863ID&#034;: &#034;A\u516c\u53f8\u4e0eB\u516c\u53f8\u91c7\u8d2d\u5408\u540c&#034;,<br \/>\n      &#034;\u6cd5\u5f8b\u98ce\u9669\u5206\u6790&#034;: &#034;1. \u98ce\u9669\u7b49\u7ea7&#xff1a;\u4e2d\\\\n2. \u98ce\u9669\u8981\u70b9&#xff1a;\u672a\u5305\u542b\u4e89\u8bae\u89e3\u51b3\u6761\u6b3e&#xff0c;\u8fdd\u7ea6\u8d23\u4efb\u8868\u8ff0\u6a21\u7cca\u3002\\\\n3. \u5efa\u8bae&#xff1a;\u8865\u5145\u4e89\u8bae\u89e3\u51b3\u6761\u6b3e&#xff0c;\u660e\u786e\u8d54\u507f\u8303\u56f4\u3002&#034;<br \/>\n    }<br \/>\n  ],<br \/>\n  &#034;\u6587\u6863\u9884\u89c8&#034;: [<br \/>\n    { &#034;\u6587\u6863ID&#034;: &#034;A\u516c\u53f8\u4e0eB\u516c\u53f8\u91c7\u8d2d\u5408\u540c&#034;, &#034;\u524d\u51e0\u767e\u5b57&#034;: &#034;\u5408\u540c\u7f16\u53f7&#xff1a;2024-A001&#8230;&#034; }<br \/>\n  ]<br \/>\n}<\/p>\n<h2>12\u3001\u6cd5\u52a1\u8f85\u52a9 &#043; \u81ea\u52a8\u4fee\u8ba2 &#043; BPM\u8054\u52a8<\/h2>\n<p>\u63a5\u4e0b\u6765\u5b9e\u73b0\u4ee5\u4e0b\u4e24\u4e2a\u529f\u80fd&#xff0c;\u6253\u9020\u771f\u6b63\u5177\u5907\u201c\u6cd5\u52a1\u8f85\u52a9 &#043; \u81ea\u52a8\u4fee\u8ba2 &#043; BPM\u8054\u52a8\u201d\u7684\u667a\u80fd\u6d41\u7a0b\u7cfb\u7edf&#xff1a;<\/p>\n<h3>\u529f\u80fd\u4e00&#xff1a;\u5c06\u6cd5\u52a1\u5206\u6790\u7ed3\u679c\u5199\u5165 BPM \u6d41\u7a0b\u5907\u6ce8\u5b57\u6bb5<\/h3>\n<h4>1. \u5b9e\u73b0\u903b\u8f91<\/h4>\n<li>\n<p>\u5728 get_bpm_with_legal_advice \u51fd\u6570\u4e2d\u5206\u6790\u6cd5\u5f8b\u98ce\u9669<\/p>\n<\/li>\n<li>\n<p>\u5c06\u5206\u6790\u7ed3\u679c\u7528\u63a5\u53e3\u5199\u5165 BPM \u7cfb\u7edf\u4e2d\u5bf9\u5e94\u6d41\u7a0b\u7684\u5907\u6ce8\u5b57\u6bb5&#xff08;\u6216\u8bc4\u8bba\u3001\u5ba1\u9605\u65e5\u5fd7&#xff09;\u00a0<\/p>\n<\/li>\n<h4>2.BPM Adapter \u589e\u52a0\u63a5\u53e3&#xff08;\u5047\u8bbe BPM \u652f\u6301 REST&#xff09;<\/h4>\n<p>\u66f4\u65b0 bpm_adapter.py&#xff1a;<\/p>\n<p>def write_bpm_comment(process_id: str, comment: str) -&gt; bool:<br \/>\n    try:<br \/>\n        # \u793a\u4f8b&#xff1a;\u5047\u8bbe\u6211\u4eec\u8c03\u7528\u672c\u5730 BPM API<br \/>\n        url &#061; f&#034;http:\/\/localhost:8080\/bpm\/api\/processes\/{process_id}\/comment&#034;<br \/>\n        response &#061; requests.post(url, json&#061;{&#034;comment&#034;: comment})<br \/>\n        return response.status_code &#061;&#061; 200<br \/>\n    except Exception as e:<br \/>\n        print(f&#034;BPM\u5199\u5165\u5907\u6ce8\u5931\u8d25&#xff1a;{e}&#034;)<br \/>\n        return False<\/p>\n<h4>3.\u66f4\u65b0 get_bpm_with_legal_advice<\/h4>\n<p>def get_bpm_with_legal_advice(process_id: str):<br \/>\n    bpm_info &#061; get_bpm_process_info(process_id)<br \/>\n    if isinstance(bpm_info, str):<br \/>\n        return f&#034;BPM\u67e5\u8be2\u5931\u8d25&#xff1a;{bpm_info}&#034;<\/p>\n<p>    docs &#061; bpm_info.get(&#034;\u6587\u6863\u5217\u8868&#034;, [])<br \/>\n    doc_contents &#061; []<br \/>\n    legal_reports &#061; []<\/p>\n<p>    for doc_id in docs:<br \/>\n        content &#061; get_document_content(doc_id)<br \/>\n        doc_contents.append({&#034;\u6587\u6863ID&#034;: doc_id, &#034;\u5185\u5bb9&#034;: content})<br \/>\n        if &#034;\u5408\u540c&#034; in doc_id or &#034;agreement&#034; in doc_id.lower():<br \/>\n            report &#061; analyze_legal_risks(content)<br \/>\n            legal_reports.append({&#034;\u6587\u6863ID&#034;: doc_id, &#034;\u6cd5\u5f8b\u98ce\u9669\u5206\u6790&#034;: report})<\/p>\n<p>    # \u7ec4\u7ec7\u5199\u5165\u5185\u5bb9<br \/>\n    summary &#061; &#034;\\\\n\\\\n&#034;.join(<br \/>\n        f&#034;&#x1f4c4;\u3010{r[&#039;\u6587\u6863ID&#039;]}\u3011\\\\n{r[&#039;\u6cd5\u5f8b\u98ce\u9669\u5206\u6790&#039;]}&#034; for r in legal_reports<br \/>\n    )<br \/>\n    comment &#061; f&#034;&#x1f6e1;\ufe0f \u6cd5\u52a1\u98ce\u9669\u5206\u6790\u5982\u4e0b&#xff1a;\\\\n{summary}&#034;<\/p>\n<p>    write_bpm_comment(process_id, comment)<\/p>\n<p>    return {<br \/>\n        &#034;\u6d41\u7a0bID&#034;: process_id,<br \/>\n        &#034;\u6cd5\u5f8b\u98ce\u9669\u62a5\u544a&#034;: legal_reports,<br \/>\n        &#034;\u5907\u6ce8\u5df2\u5199\u5165BPM&#034;: True,<br \/>\n    }<\/p>\n<h3>\u529f\u80fd\u4e8c&#xff1a;AI \u81ea\u52a8\u4fee\u8ba2\u5408\u540c\u8349\u7a3f<\/h3>\n<p>\u6211\u4eec\u8ba9 Claude \u6216 GPT \u76f4\u63a5\u7ed9\u51fa\u4fee\u6539\u5efa\u8bae\u6216\u8fd4\u56de\u4f18\u5316\u540e\u7684\u5408\u540c\u8349\u7a3f\u6bb5\u843d\u3002<\/p>\n<h4>1.\u6a21\u5757\u65b0\u589e&#xff1a;contract_editor.py<\/h4>\n<p># contract_editor.py<br \/>\nimport os<br \/>\nimport openai<\/p>\n<p>openai.api_key &#061; os.getenv(&#034;OPENAI_API_KEY&#034;)<\/p>\n<p>def revise_contract(contract_text: str, legal_issues: str) -&gt; str:<br \/>\n    prompt &#061; f&#034;&#034;&#034;<br \/>\n\u4f60\u662f\u6cd5\u5f8b\u8bed\u8a00\u7f16\u8f91\u4e13\u5bb6\u3002\u8bf7\u6839\u636e\u4ee5\u4e0b\u6cd5\u5f8b\u98ce\u9669\u70b9&#xff0c;\u4f18\u5316\u4fee\u8ba2\u8fd9\u4efd\u5408\u540c\u5185\u5bb9&#xff0c;\u4f7f\u5176\u66f4\u52a0\u5408\u89c4\u3001\u6e05\u6670\u3002\u4e0d\u8981\u8fc7\u5ea6\u6da6\u8272&#xff0c;\u53ea\u505a\u6cd5\u5f8b\u5fc5\u8981\u4fee\u6b63\u3002<\/p>\n<p>\u3010\u6cd5\u5f8b\u95ee\u9898\u3011&#xff1a;<br \/>\n{legal_issues}<\/p>\n<p>\u3010\u539f\u59cb\u5408\u540c\u7247\u6bb5\u3011&#xff1a;<br \/>\n{contract_text[:3000]}<\/p>\n<p>\u8bf7\u8fd4\u56de\u4f18\u5316\u540e\u7684\u4fee\u8ba2\u7248\u5408\u540c\u6587\u672c&#xff1a;<br \/>\n&#034;&#034;&#034;<\/p>\n<p>    try:<br \/>\n        response &#061; openai.ChatCompletion.create(<br \/>\n            model&#061;&#034;gpt-4&#034;,<br \/>\n            messages&#061;[{&#034;role&#034;: &#034;user&#034;, &#034;content&#034;: prompt}],<br \/>\n            temperature&#061;0.3,<br \/>\n            max_tokens&#061;800,<br \/>\n        )<br \/>\n        return response.choices[0].message.content.strip()<br \/>\n    except Exception as e:<br \/>\n        return f&#034;\u5408\u540c\u4fee\u8ba2\u5931\u8d25&#xff1a;{e}&#034;<\/p>\n<h4>2.\u66f4\u65b0\u7ec4\u5408\u6a21\u5757&#xff08;\u5982 bpm_ecm_combined.py&#xff09;<\/h4>\n<p>\u52a0\u5165\u4fee\u8ba2\u5efa\u8bae\u529f\u80fd&#xff1a;<\/p>\n<p>from contract_editor import revise_contract<\/p>\n<p>def get_legal_advice_with_rewrite(process_id: str):<br \/>\n    bpm_info &#061; get_bpm_process_info(process_id)<br \/>\n    docs &#061; bpm_info.get(&#034;\u6587\u6863\u5217\u8868&#034;, [])<br \/>\n    legal_reports &#061; []<br \/>\n    revised_docs &#061; []<\/p>\n<p>    for doc_id in docs:<br \/>\n        content &#061; get_document_content(doc_id)<br \/>\n        if &#034;\u5408\u540c&#034; in doc_id or &#034;agreement&#034; in doc_id.lower():<br \/>\n            legal_analysis &#061; analyze_legal_risks(content)<br \/>\n            legal_reports.append({<br \/>\n                &#034;\u6587\u6863ID&#034;: doc_id,<br \/>\n                &#034;\u6cd5\u5f8b\u98ce\u9669\u5206\u6790&#034;: legal_analysis<br \/>\n            })<br \/>\n            revised_text &#061; revise_contract(content, legal_analysis)<br \/>\n            revised_docs.append({<br \/>\n                &#034;\u6587\u6863ID&#034;: doc_id,<br \/>\n                &#034;\u4fee\u8ba2\u5efa\u8bae&#034;: revised_text<br \/>\n            })<\/p>\n<p>    return {<br \/>\n        &#034;\u6d41\u7a0bID&#034;: process_id,<br \/>\n        &#034;\u6cd5\u5f8b\u98ce\u9669\u62a5\u544a&#034;: legal_reports,<br \/>\n        &#034;\u5408\u540c\u4fee\u8ba2\u5efa\u8bae&#034;: revised_docs<br \/>\n    }<\/p>\n<h4>3.API \u8c03\u7528\u65b9\u5f0f<\/h4>\n<h5>POST \/query<\/h5>\n<p>{<br \/>\n  &#034;input&#034;: &#034;process-20240318-A\u5408\u540c\u5ba1\u6279&#034;,<br \/>\n  &#034;context&#034;: {<br \/>\n    &#034;tools&#034;: [&#034;legal_risk_analysis&#034;, &#034;rewrite_contract&#034;]<br \/>\n  }<br \/>\n}<\/p>\n<h4>4.\u6700\u7ec8\u8fd4\u56de\u7ed3\u6784\u793a\u4f8b\u00a0<\/h4>\n<p>{<br \/>\n  &#034;\u6d41\u7a0bID&#034;: &#034;process-20240318-A\u5408\u540c\u5ba1\u6279&#034;,<br \/>\n  &#034;\u6cd5\u5f8b\u98ce\u9669\u62a5\u544a&#034;: [<br \/>\n    {<br \/>\n      &#034;\u6587\u6863ID&#034;: &#034;\u91c7\u8d2d\u5408\u540c-A001&#034;,<br \/>\n      &#034;\u6cd5\u5f8b\u98ce\u9669\u5206\u6790&#034;: &#034;1. \u98ce\u9669\u7b49\u7ea7&#xff1a;\u4e2d\\\\n2. \u95ee\u9898&#xff1a;\u7f3a\u5c11\u8fdd\u7ea6\u8d54\u507f\u673a\u5236\\\\n3. \u5efa\u8bae&#xff1a;\u52a0\u5165\u8d54\u507f\u6761\u6b3e&#034;<br \/>\n    }<br \/>\n  ],<br \/>\n  &#034;\u5408\u540c\u4fee\u8ba2\u5efa\u8bae&#034;: [<br \/>\n    {<br \/>\n      &#034;\u6587\u6863ID&#034;: &#034;\u91c7\u8d2d\u5408\u540c-A001&#034;,<br \/>\n      &#034;\u4fee\u8ba2\u5efa\u8bae&#034;: &#034;\u2026\u672c\u534f\u8bae\u7b2c\u516d\u6761\u65b0\u589e\u5982\u4e0b\u5185\u5bb9&#xff1a;\u82e5\u4efb\u4f55\u4e00\u65b9\u8fdd\u7ea6&#xff0c;\u5e94\u8d54\u507f\u5bf9\u65b9\u56e0\u6b64\u9020\u6210\u7684\u5b9e\u9645\u7ecf\u6d4e\u635f\u5931\u2026&#034;<br \/>\n    }<br \/>\n  ]<br \/>\n}<\/p>\n<h3>\u603b\u7ed3<\/h3>\n<table>\n<tr>\u529f\u80fd\u72b6\u6001<\/tr>\n<tbody>\n<tr>\n<td>\u2705 \u6cd5\u52a1\u98ce\u9669\u8bc6\u522b<\/td>\n<td>\u5b8c\u6210<\/td>\n<\/tr>\n<tr>\n<td>\u2705 \u98ce\u9669\u5199\u5165 BPM \u6d41\u7a0b\u5907\u6ce8<\/td>\n<td>\u5b8c\u6210<\/td>\n<\/tr>\n<tr>\n<td>\u2705 AI \u81ea\u52a8\u4fee\u8ba2\u5408\u540c\u8349\u7a3f<\/td>\n<td>\u5b8c\u6210<\/td>\n<\/tr>\n<tr>\n<td>\u2705 \u8fd4\u56de\u7ed3\u6784\u5316\u98ce\u9669 &#043; \u5efa\u8bae<\/td>\n<td>\u5df2\u5b8c\u6210<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>13\u3001\u591a Agent \u6295\u7968\u673a\u5236<\/h2>\n<p>\u591a Agent \u6295\u7968\u673a\u5236&#xff0c;\u6a21\u62df\u591a\u4e2a\u6cd5\u5f8b\u4e13\u5bb6\u5bf9\u5408\u540c\u6761\u6b3e\u8fdb\u884c\u72ec\u7acb\u5224\u65ad &#043; \u6295\u7968\u8868\u51b3&#xff0c;\u786e\u4fdd\u7ed3\u8bba\u66f4\u5177\u6743\u5a01\u6027\u548c\u7a33\u5065\u6027\u3002<\/p>\n<h3>1.\u4ec0\u4e48\u662f\u591a Agent \u6295\u7968\u673a\u5236&#xff1f;<\/h3>\n<p>\u591a\u4e2a\u5927\u6a21\u578b&#xff08;Agent&#xff09;&#xff0c;\u72ec\u7acb\u5206\u6790\u5408\u540c\u98ce\u9669&#xff0c;\u7136\u540e&#xff1a;<\/p>\n<li>\n<p>\u5404\u81ea\u8f93\u51fa\u5224\u65ad&#xff08;\u98ce\u9669\u7b49\u7ea7\u3001\u9ad8\u4eae\u95ee\u9898\u3001\u5efa\u8bae&#xff09;<\/p>\n<\/li>\n<li>\n<p>\u7cfb\u7edf\u81ea\u52a8\u5bf9\u6bd4\u610f\u89c1&#xff0c;\u5f52\u7eb3\u5171\u8bc6<\/p>\n<\/li>\n<li>\n<p>\u82e5\u51b2\u7a81&#xff0c;\u5219\u8f93\u51fa\u201c\u26a0\ufe0f \u5b58\u5728\u5206\u6b67&#xff0c;\u8bf7\u4eba\u5de5\u786e\u8ba4\u201d\u00a0<\/p>\n<\/li>\n<h3>2.\u6295\u7968\u67b6\u6784\u8bbe\u8ba1<\/h3>\n<p>                   \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510<br \/>\n                   \u2502 Contract   \u2502<br \/>\n                   \u2502 Text       \u2502<br \/>\n                   \u2514\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518<br \/>\n                        \u2502<br \/>\n        \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510<br \/>\n        \u25bc               \u25bc                \u25bc<br \/>\n  Claude Agent     GPT Agent       Mistral Agent<br \/>\n (\u98ce\u9669\u5206\u6790A)       (\u98ce\u9669\u5206\u6790B)       (\u98ce\u9669\u5206\u6790C)<br \/>\n        \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518<br \/>\n                        \u25bc<br \/>\n              &#x1f916; \u5408\u5e76 &amp; \u6295\u7968\u5224\u65ad\u6a21\u5757<br \/>\n                        \u25bc<br \/>\n               &#x1f4dd; \u6700\u7ec8\u98ce\u9669\u5171\u8bc6 &#043; \u5206\u6b67\u6807\u8bb0<\/p>\n<h3>3.\u6b65\u9aa4\u4e00&#xff1a;\u521b\u5efa\u591a\u6a21\u578b\u5206\u6790\u51fd\u6570<\/h3>\n<p>\u6211\u4eec\u65b0\u589e multi_agent_legal.py \u6a21\u5757&#xff1a;<\/p>\n<p># multi_agent_legal.py<br \/>\nfrom legal_advisor import analyze_legal_risks_with_model<\/p>\n<p>def multi_agent_vote(contract_text: str):<br \/>\n    models &#061; {<br \/>\n        &#034;claude&#034;: &#034;claude-3-opus-20240229&#034;,<br \/>\n        &#034;gpt&#034;: &#034;gpt-4&#034;,<br \/>\n        &#034;mistral&#034;: &#034;mistral-7b-instruct&#034;<br \/>\n    }<\/p>\n<p>    results &#061; {}<br \/>\n    for name, model in models.items():<br \/>\n        result &#061; analyze_legal_risks_with_model(contract_text, model)<br \/>\n        results[name] &#061; result<\/p>\n<p>    # \u7b80\u5355\u6295\u7968\u903b\u8f91&#xff08;\u53ef\u6269\u5c55\u4e3a NLP \u5171\u8bc6\u5224\u65ad&#xff09;<br \/>\n    risk_levels &#061; {}<br \/>\n    for name, text in results.items():<br \/>\n        if &#034;\u9ad8&#034; in text:<br \/>\n            risk_levels[name] &#061; &#034;\u9ad8&#034;<br \/>\n        elif &#034;\u4e2d&#034; in text:<br \/>\n            risk_levels[name] &#061; &#034;\u4e2d&#034;<br \/>\n        else:<br \/>\n            risk_levels[name] &#061; &#034;\u4f4e&#034;<\/p>\n<p>    votes &#061; list(risk_levels.values())<br \/>\n    if votes.count(&#034;\u9ad8&#034;) &gt;&#061; 2:<br \/>\n        final_level &#061; &#034;\u9ad8&#034;<br \/>\n    elif votes.count(&#034;\u4e2d&#034;) &gt;&#061; 2:<br \/>\n        final_level &#061; &#034;\u4e2d&#034;<br \/>\n    else:<br \/>\n        final_level &#061; &#034;\u4f4e&#034;<\/p>\n<p>    consensus &#061; {<br \/>\n        &#034;\u6700\u7ec8\u98ce\u9669\u7b49\u7ea7&#034;: final_level,<br \/>\n        &#034;\u5404Agent\u5224\u65ad&#034;: risk_levels,<br \/>\n        &#034;\u8be6\u7ec6\u62a5\u544a&#034;: results<br \/>\n    }<\/p>\n<p>    return consensus<\/p>\n<h3>4.\u6b65\u9aa4\u4e8c&#xff1a;\u652f\u6301\u4e0d\u540c\u6a21\u578b\u8c03\u7528&#xff08;\u4fee\u6539 legal_advisor.py&#xff09;\u00a0<\/h3>\n<p>def analyze_legal_risks_with_model(doc_text: str, model: str) -&gt; str:<br \/>\n    prompt &#061; f&#034;&#034;&#034;<br \/>\n\u4f60\u662f\u5408\u540c\u6cd5\u5f8b\u5ba1\u67e5\u4e13\u5bb6&#xff0c;\u8bf7\u5206\u6790\u4ee5\u4e0b\u5408\u540c\u6bb5\u843d\u7684\u6cd5\u5f8b\u98ce\u9669\u3001\u7f3a\u9677&#xff0c;\u5e76\u63d0\u51fa\u4fee\u6539\u5efa\u8bae\u3002<\/p>\n<p>\u3010\u5408\u540c\u5185\u5bb9\u3011&#xff1a;<br \/>\n{doc_text[:3000]}<br \/>\n&#034;&#034;&#034;<\/p>\n<p>    try:<br \/>\n        response &#061; openai.ChatCompletion.create(<br \/>\n            model&#061;model,<br \/>\n            messages&#061;[{&#034;role&#034;: &#034;user&#034;, &#034;content&#034;: prompt}],<br \/>\n            temperature&#061;0.2,<br \/>\n            max_tokens&#061;512,<br \/>\n        )<br \/>\n        return response.choices[0].message.content.strip()<br \/>\n    except Exception as e:<br \/>\n        return f&#034;[{model}] \u98ce\u9669\u5206\u6790\u5931\u8d25&#xff1a;{e}&#034;<\/p>\n<h3>5.\u6b65\u9aa4\u4e09&#xff1a;\u5728\u6d41\u7a0b\u4e2d\u5f15\u5165\u6295\u7968\u5206\u6790<\/h3>\n<p>\u66f4\u65b0\u7ec4\u5408\u6a21\u5757&#xff0c;\u5982&#xff1a;<\/p>\n<p>from multi_agent_legal import multi_agent_vote<\/p>\n<p>def get_legal_vote_result(process_id: str):<br \/>\n    bpm_info &#061; get_bpm_process_info(process_id)<br \/>\n    docs &#061; bpm_info.get(&#034;\u6587\u6863\u5217\u8868&#034;, [])<br \/>\n    vote_reports &#061; []<\/p>\n<p>    for doc_id in docs:<br \/>\n        content &#061; get_document_content(doc_id)<br \/>\n        if &#034;\u5408\u540c&#034; in doc_id or &#034;agreement&#034; in doc_id.lower():<br \/>\n            vote_result &#061; multi_agent_vote(content)<br \/>\n            vote_reports.append({<br \/>\n                &#034;\u6587\u6863ID&#034;: doc_id,<br \/>\n                &#034;\u6700\u7ec8\u98ce\u9669\u7b49\u7ea7&#034;: vote_result[&#034;\u6700\u7ec8\u98ce\u9669\u7b49\u7ea7&#034;],<br \/>\n                &#034;\u591aAgent\u5224\u65ad&#034;: vote_result[&#034;\u5404Agent\u5224\u65ad&#034;],<br \/>\n                &#034;\u8be6\u7ec6\u62a5\u544a&#034;: vote_result[&#034;\u8be6\u7ec6\u62a5\u544a&#034;]<br \/>\n            })<\/p>\n<p>    return {<br \/>\n        &#034;\u6d41\u7a0bID&#034;: process_id,<br \/>\n        &#034;\u5408\u540c\u591aAgent\u98ce\u9669\u5171\u8bc6\u62a5\u544a&#034;: vote_reports<br \/>\n    }<\/p>\n<h3>6.\u793a\u4f8b\u8fd4\u56de\u7ed3\u6784<\/h3>\n<p>{<br \/>\n  &#034;\u6d41\u7a0bID&#034;: &#034;A\u5408\u540c\u5ba1\u6279&#034;,<br \/>\n  &#034;\u5408\u540c\u591aAgent\u98ce\u9669\u5171\u8bc6\u62a5\u544a&#034;: [<br \/>\n    {<br \/>\n      &#034;\u6587\u6863ID&#034;: &#034;\u91c7\u8d2d\u5408\u540c-A001&#034;,<br \/>\n      &#034;\u6700\u7ec8\u98ce\u9669\u7b49\u7ea7&#034;: &#034;\u4e2d&#034;,<br \/>\n      &#034;\u591aAgent\u5224\u65ad&#034;: {<br \/>\n        &#034;claude&#034;: &#034;\u4e2d&#034;,<br \/>\n        &#034;gpt&#034;: &#034;\u4e2d&#034;,<br \/>\n        &#034;mistral&#034;: &#034;\u4f4e&#034;<br \/>\n      },<br \/>\n      &#034;\u8be6\u7ec6\u62a5\u544a&#034;: {<br \/>\n        &#034;claude&#034;: &#034;\u5b58\u5728\u4ed8\u6b3e\u6761\u6b3e\u6a21\u7cca\u7b49\u95ee\u9898&#034;,<br \/>\n        &#034;gpt&#034;: &#034;\u672a\u6307\u660e\u4e89\u8bae\u89e3\u51b3\u65b9\u5f0f&#xff0c;\u5efa\u8bae\u8865\u5145&#034;,<br \/>\n        &#034;mistral&#034;: &#034;\u6574\u4f53\u98ce\u9669\u8f83\u4f4e&#xff0c;\u4ec5\u5efa\u8bae\u6dfb\u52a0\u4ed8\u6b3e\u8282\u70b9&#034;<br \/>\n      }<br \/>\n    }<br \/>\n  ]<br \/>\n}<\/p>\n<h2>14\u3001\u529f\u80fd\u589e\u5f3a<\/h2>\n<h3>\u529f\u80fd 1&#xff1a;\u5728 ECM \u4e2d\u521b\u5efa\u201c\u6cd5\u5f8b\u98ce\u9669\u5ba1\u67e5\u8bb0\u5f55\u201d\u6587\u6863<\/h3>\n<h4>\u6a21\u5757\u65b0\u589e&#xff1a;ecm_writer.py<\/h4>\n<p># ecm_writer.py<br \/>\nimport requests<\/p>\n<p>def create_legal_review_doc(doc_id: str, vote_result: dict) -&gt; bool:<br \/>\n    payload &#061; {<br \/>\n        &#034;title&#034;: f&#034;\u6cd5\u5f8b\u98ce\u9669\u5206\u6790\u62a5\u544a &#8211; {doc_id}&#034;,<br \/>\n        &#034;metadata&#034;: {<br \/>\n            &#034;\u539f\u6587\u6863ID&#034;: doc_id,<br \/>\n            &#034;\u98ce\u9669\u7b49\u7ea7&#034;: vote_result[&#034;\u6700\u7ec8\u98ce\u9669\u7b49\u7ea7&#034;],<br \/>\n            &#034;\u591aAgent\u5224\u65ad&#034;: str(vote_result[&#034;\u5404Agent\u5224\u65ad&#034;])<br \/>\n        },<br \/>\n        &#034;content&#034;: vote_result[&#034;\u8be6\u7ec6\u62a5\u544a&#034;]<br \/>\n    }<\/p>\n<p>    try:<br \/>\n        res &#061; requests.post(&#034;http:\/\/localhost:8080\/ecm\/api\/create_doc&#034;, json&#061;payload)<br \/>\n        return res.status_code &#061;&#061; 200<br \/>\n    except Exception as e:<br \/>\n        print(f&#034;ECM\u5199\u5165\u5931\u8d25&#xff1a;{e}&#034;)<br \/>\n        return False<\/p>\n<h3>\u529f\u80fd 2&#xff1a;BPM \u6d41\u7a0b\u5907\u6ce8\u4e2d\u5199\u5165\u6295\u7968\u7ed3\u679c\u6458\u8981<\/h3>\n<p>\u590d\u7528\u4e4b\u524d\u7684 write_bpm_comment&#xff1a;<\/p>\n<p>def summarize_vote(vote_result: dict) -&gt; str:<br \/>\n    votes &#061; vote_result[&#034;\u5404Agent\u5224\u65ad&#034;]<br \/>\n    return f&#034;&#034;&#034;&#x1f5f3;\ufe0f \u6cd5\u52a1Agent\u6295\u7968\u7ed3\u679c&#xff1a;<br \/>\nClaude&#xff1a;{votes.get(&#039;claude&#039;)}<br \/>\nGPT&#xff1a;{votes.get(&#039;gpt&#039;)}<br \/>\nMistral&#xff1a;{votes.get(&#039;mistral&#039;)}<br \/>\n\u6700\u7ec8\u98ce\u9669\u7b49\u7ea7&#xff1a;{vote_result[&#039;\u6700\u7ec8\u98ce\u9669\u7b49\u7ea7&#039;]}&#034;&#034;&#034;<\/p>\n<p>\u5728\u6d41\u7a0b\u4e2d\u8fd9\u6837\u8c03\u7528&#xff1a;<\/p>\n<p>comment &#061; summarize_vote(vote_result)<br \/>\nwrite_bpm_comment(process_id, comment)<\/p>\n<h3>\u529f\u80fd 3&#xff1a;\u524d\u7aef\u4eea\u8868\u76d8\u663e\u793a\u6295\u7968 &amp; \u5408\u540c\u98ce\u9669\u6570\u636e<\/h3>\n<h4>\u4f7f\u7528 React &#043; Tailwind \u6784\u5efa\u4e00\u4e2a\u4eea\u8868\u76d8&#xff08;\u5efa\u8bae\u7528 shadcn\/ui&#xff09;<\/h4>\n<p>\u6211\u4eec\u6765\u751f\u6210\u4e00\u4e2a\u53ef\u90e8\u7f72\u7684 React \u9875\u9762&#xff1a;<\/p>\n<p>\/\/ components\/LegalDashboard.tsx<br \/>\nimport { Card, CardContent } from &#034;&#064;\/components\/ui\/card&#034;<br \/>\nimport { BarChart2, ShieldAlert } from &#034;lucide-react&#034;<\/p>\n<p>export default function LegalDashboard({ data }) {<br \/>\n  return (<br \/>\n    &lt;div className&#061;&#034;grid gap-4 p-6 grid-cols-1 md:grid-cols-2&#034;&gt;<br \/>\n      {data.map((item: any) &#061;&gt; (<br \/>\n        &lt;Card key&#061;{item.\u6587\u6863ID} className&#061;&#034;shadow-lg rounded-2xl&#034;&gt;<br \/>\n          &lt;CardContent className&#061;&#034;p-4 space-y-2&#034;&gt;<br \/>\n            &lt;div className&#061;&#034;flex justify-between items-center&#034;&gt;<br \/>\n              &lt;h2 className&#061;&#034;text-xl font-bold&#034;&gt;{item.\u6587\u6863ID}&lt;\/h2&gt;<br \/>\n              &lt;span className&#061;{&#096;text-sm px-2 py-1 rounded-xl ${item.\u6700\u7ec8\u98ce\u9669\u7b49\u7ea7 &#061;&#061;&#061; &#034;\u9ad8&#034; ? &#034;bg-red-100 text-red-700&#034; : item.\u6700\u7ec8\u98ce\u9669\u7b49\u7ea7 &#061;&#061;&#061; &#034;\u4e2d&#034; ? &#034;bg-yellow-100 text-yellow-800&#034; : &#034;bg-green-100 text-green-700&#034;}&#096;}&gt;<br \/>\n                \u98ce\u9669&#xff1a;{item.\u6700\u7ec8\u98ce\u9669\u7b49\u7ea7}<br \/>\n              &lt;\/span&gt;<br \/>\n            &lt;\/div&gt;<br \/>\n            &lt;div className&#061;&#034;text-sm&#034;&gt;<br \/>\n              &lt;p&gt;&lt;ShieldAlert className&#061;&#034;inline mr-1&#034; \/&gt; Claude&#xff1a;{item.\u591aAgent\u5224\u65ad.claude}&lt;\/p&gt;<br \/>\n              &lt;p&gt;&lt;ShieldAlert className&#061;&#034;inline mr-1&#034; \/&gt; GPT&#xff1a;{item.\u591aAgent\u5224\u65ad.gpt}&lt;\/p&gt;<br \/>\n              &lt;p&gt;&lt;ShieldAlert className&#061;&#034;inline mr-1&#034; \/&gt; Mistral&#xff1a;{item.\u591aAgent\u5224\u65ad.mistral}&lt;\/p&gt;<br \/>\n            &lt;\/div&gt;<br \/>\n            &lt;details className&#061;&#034;text-xs mt-2&#034;&gt;<br \/>\n              &lt;summary className&#061;&#034;cursor-pointer&#034;&gt;&#x1f4dd; \u67e5\u770b\u8be6\u7ec6\u62a5\u544a&lt;\/summary&gt;<br \/>\n              &lt;pre className&#061;&#034;whitespace-pre-wrap mt-1&#034;&gt;{JSON.stringify(item.\u8be6\u7ec6\u62a5\u544a, null, 2)}&lt;\/pre&gt;<br \/>\n            &lt;\/details&gt;<br \/>\n          &lt;\/CardContent&gt;<br \/>\n        &lt;\/Card&gt;<br \/>\n      ))}<br \/>\n    &lt;\/div&gt;<br \/>\n  )<br \/>\n}<\/p>\n<p>\u00a0\u6570\u636e\u53ef\u901a\u8fc7 \/api\/legal_risks \u52a8\u6001\u83b7\u53d6\u3002<\/p>\n<h3>\u603b\u96c6\u6210\u51fd\u6570&#xff08;\u4e3b\u903b\u8f91&#xff09;<\/h3>\n<p>def analyze_contract_process(process_id: str):<br \/>\n    bpm_info &#061; get_bpm_process_info(process_id)<br \/>\n    vote_reports &#061; []<\/p>\n<p>    for doc_id in bpm_info.get(&#034;\u6587\u6863\u5217\u8868&#034;, []):<br \/>\n        content &#061; get_document_content(doc_id)<br \/>\n        if &#034;\u5408\u540c&#034; in doc_id:<br \/>\n            vote_result &#061; multi_agent_vote(content)<\/p>\n<p>            # \u5199\u5165 BPM<br \/>\n            comment &#061; summarize_vote(vote_result)<br \/>\n            write_bpm_comment(process_id, comment)<\/p>\n<p>            # \u5199\u5165 ECM<br \/>\n            create_legal_review_doc(doc_id, vote_result)<\/p>\n<p>            vote_reports.append({<br \/>\n                &#034;\u6587\u6863ID&#034;: doc_id,<br \/>\n                **vote_result<br \/>\n            })<\/p>\n<p>    return vote_reports<\/p>\n<h3>\u6700\u7ec8\u7cfb\u7edf\u67b6\u6784\u4e00\u89c8<\/h3>\n<p>&#x1f4c4; \u6587\u6863\u63d0\u53d6 \u2192 &#x1f9e0; \u591aAgent\u5206\u6790 \u2192 &#x1f5f3;\ufe0f \u6295\u7968\u5f52\u7eb3<br \/>\n     \u2502             \u2502               \u2502<br \/>\n     \u25bc             \u25bc               \u25bc<br \/>\n&#x1f4ce; ECM\u6587\u6863     &#x1f4dd; BPM\u5907\u6ce8     &#x1f4ca; \u524d\u7aef\u4eea\u8868\u76d8<\/p>\n<h2>15\u3001\u589e\u52a0\u524d\u7aef\u6570\u636e\u6e90\u3001\u90ae\u4ef6\u5408\u89c4\u901a\u77e5\u3001\u628aReact\u524d\u7aef\u90e8\u7f72\u5230Docker\u91cc<\/h2>\n<h3>\u6b65\u9aa4\u4e00&#xff1a;FastAPI \u63d0\u4f9b \/api\/legal_risks \u63a5\u53e3&#xff08;\u524d\u7aef\u6570\u636e\u6e90&#xff09;<\/h3>\n<h4>\u65b0\u5efa FastAPI \u8def\u7531 routes\/legal_api.py<\/h4>\n<p># routes\/legal_api.py<br \/>\nfrom fastapi import APIRouter<br \/>\nfrom fastapi.responses import JSONResponse<br \/>\nfrom backend.legal_workflow import analyze_contract_process<\/p>\n<p>router &#061; APIRouter()<\/p>\n<p>&#064;router.get(&#034;\/api\/legal_risks&#034;)<br \/>\ndef get_legal_risks(process_id: str):<br \/>\n    try:<br \/>\n        report &#061; analyze_contract_process(process_id)<br \/>\n        return JSONResponse(content&#061;report)<br \/>\n    except Exception as e:<br \/>\n        return JSONResponse(status_code&#061;500, content&#061;{&#034;error&#034;: str(e)})<\/p>\n<h4>\u4e3b\u670d\u52a1\u5f15\u5165\u8def\u7531&#xff08;main.py&#xff09;<\/h4>\n<p># main.py<br \/>\nfrom fastapi import FastAPI<br \/>\nfrom routes import legal_api<\/p>\n<p>app &#061; FastAPI()<br \/>\napp.include_router(legal_api.router)<\/p>\n<p>\u00a0\u73b0\u5728\u4f60\u53ea\u8981\u8bbf\u95ee&#xff1a;<\/p>\n<p>http:\/\/localhost:8000\/api\/legal_risks?process_id&#061;A\u5408\u540c\u5ba1\u6279<\/p>\n<p>\u5373\u53ef\u8fd4\u56de JSON \u62a5\u544a\u7ed9\u524d\u7aef\u7528&#xff01;<\/p>\n<h3>\u6b65\u9aa4\u4e8c&#xff1a;\u6dfb\u52a0\u90ae\u4ef6\u901a\u77e5\u5408\u89c4\u5458\u529f\u80fd<\/h3>\n<p>\u6211\u4eec\u6dfb\u52a0\u4e00\u4e2a\u901a\u7528\u7684\u90ae\u4ef6\u6a21\u5757 utils\/email_notify.py&#xff1a;<\/p>\n<p># utils\/email_notify.py<br \/>\nimport smtplib<br \/>\nfrom email.mime.text import MIMEText<\/p>\n<p>SMTP_SERVER &#061; &#034;smtp.example.com&#034;<br \/>\nSMTP_PORT &#061; 587<br \/>\nSMTP_USER &#061; &#034;your_user&#064;example.com&#034;<br \/>\nSMTP_PASS &#061; &#034;your_password&#034;<\/p>\n<p>def send_email(to: str, subject: str, body: str):<br \/>\n    msg &#061; MIMEText(body, &#034;plain&#034;, &#034;utf-8&#034;)<br \/>\n    msg[&#034;Subject&#034;] &#061; subject<br \/>\n    msg[&#034;From&#034;] &#061; SMTP_USER<br \/>\n    msg[&#034;To&#034;] &#061; to<\/p>\n<p>    with smtplib.SMTP(SMTP_SERVER, SMTP_PORT) as server:<br \/>\n        server.starttls()<br \/>\n        server.login(SMTP_USER, SMTP_PASS)<br \/>\n        server.sendmail(SMTP_USER, to, msg.as_string())<\/p>\n<p>\u7136\u540e\u5728 analyze_contract_process() \u4e2d\u52a0\u5165\u901a\u77e5\u903b\u8f91&#xff1a;<\/p>\n<p>from utils.email_notify import send_email<\/p>\n<p># \u5185\u90e8\u6d41\u7a0b\u4e2d<br \/>\nsend_email(<br \/>\n    to&#061;&#034;compliance&#064;company.com&#034;,<br \/>\n    subject&#061;f&#034;\u3010\u65b0\u5408\u540c\u98ce\u9669\u62a5\u544a\u3011{doc_id}&#034;,<br \/>\n    body&#061;f&#034;\u98ce\u9669\u7b49\u7ea7&#xff1a;{vote_result[&#039;\u6700\u7ec8\u98ce\u9669\u7b49\u7ea7&#039;]}\\\\n\u8bf7\u767b\u5f55\u4eea\u8868\u76d8\u67e5\u770b\u8be6\u60c5\u3002&#034;<br \/>\n)<\/p>\n<h3>\u6b65\u9aa4\u4e09&#xff1a;React \u4eea\u8868\u76d8\u90e8\u7f72\u6210 Docker \u955c\u50cf<\/h3>\n<h4>\u6587\u4ef6\u7ed3\u6784<\/h4>\n<p>legal-dashboard\/<br \/>\n\u251c\u2500\u2500 public\/<br \/>\n\u251c\u2500\u2500 src\/<br \/>\n\u2502   \u2514\u2500\u2500 components\/LegalDashboard.tsx<br \/>\n\u251c\u2500\u2500 .dockerignore<br \/>\n\u251c\u2500\u2500 Dockerfile<br \/>\n\u251c\u2500\u2500 package.json<br \/>\n\u2514\u2500\u2500 vite.config.ts<\/p>\n<h4>Dockerfile \u793a\u4f8b&#xff08;Dockefile&#xff09;<\/h4>\n<p># Step 1: Build<br \/>\nFROM node:20 AS builder<br \/>\nWORKDIR \/app<br \/>\nCOPY . .<br \/>\nRUN npm install &amp;&amp; npm run build<\/p>\n<p># Step 2: Serve with nginx<br \/>\nFROM nginx:alpine<br \/>\nCOPY &#8211;from&#061;builder \/app\/dist \/usr\/share\/nginx\/html<br \/>\nEXPOSE 80<br \/>\nCMD [&#034;nginx&#034;, &#034;-g&#034;, &#034;daemon off;&#034;]<\/p>\n<h4>.dockerignore&#xff08;Nginx&#xff09;<\/h4>\n<p>node_modules<br \/>\ndist<\/p>\n<h4>\u6784\u5efa\u4e0e\u8fd0\u884c<\/h4>\n<p>docker build -t legal-dashboard .<br \/>\ndocker run -d -p 3000:80 legal-dashboard<\/p>\n<p>\u7136\u540e\u8bbf\u95ee&#xff1a;<\/p>\n<p>http:\/\/localhost:3000<\/p>\n<p>\u524d\u7aef\u5c06\u81ea\u52a8\u8bbf\u95ee&#xff1a;<\/p>\n<p>http:\/\/localhost:8000\/api\/legal_risks?process_id&#061;A\u5408\u540c\u5ba1\u6279<\/p>\n<p>\u5e76\u5c55\u793a\u6700\u65b0\u7684\u6295\u7968\u7ed3\u679c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.3k\u6b21\uff0c\u70b9\u8d5e35\u6b21\uff0c\u6536\u85cf31\u6b21\u3002MCP Server \u5176\u5b9e\u5c31\u662f\u4e00\u4e2a\u7b26\u5408 MCP \u534f\u8bae\u89c4\u8303 \u7684 Web Server\uff0c\u672c\u8d28\u4e0a\u662f\u4e00\u4e2a\u80fd\u63a5\u6536 JSON \u8bf7\u6c42\u3001\u6309\u9700\u8bbf\u95ee\u672c\u5730\u8d44\u6e90\uff08\u6587\u4ef6\u3001\u6570\u636e\u5e93\u3001API \u7b49\uff09\u5e76\u8fd4\u56de\u7ed3\u679c\u7684 REST API \u670d\u52a1\u3002_mcp pdf\u63d0\u53d6<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[916,915,50],"topic":[],"class_list":["post-14520","post","type-post","status-publish","format-standard","hentry","category-server","tag-bpm","tag-ecm","tag-50"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u90e8\u7f72MCP\u670d\u52a1\u5668\u793a\u4f8b\uff1aIBM BPM\/ECM\u589e\u52a0AI\u529f\u80fd - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/14520.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u90e8\u7f72MCP\u670d\u52a1\u5668\u793a\u4f8b\uff1aIBM BPM\/ECM\u589e\u52a0AI\u529f\u80fd - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.3k\u6b21\uff0c\u70b9\u8d5e35\u6b21\uff0c\u6536\u85cf31\u6b21\u3002MCP Server \u5176\u5b9e\u5c31\u662f\u4e00\u4e2a\u7b26\u5408 MCP \u534f\u8bae\u89c4\u8303 \u7684 Web Server\uff0c\u672c\u8d28\u4e0a\u662f\u4e00\u4e2a\u80fd\u63a5\u6536 JSON \u8bf7\u6c42\u3001\u6309\u9700\u8bbf\u95ee\u672c\u5730\u8d44\u6e90\uff08\u6587\u4ef6\u3001\u6570\u636e\u5e93\u3001API \u7b49\uff09\u5e76\u8fd4\u56de\u7ed3\u679c\u7684 REST API \u670d\u52a1\u3002_mcp pdf\u63d0\u53d6\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/14520.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-18T13:17:43+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"24 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/14520.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/14520.html\",\"name\":\"\u90e8\u7f72MCP\u670d\u52a1\u5668\u793a\u4f8b\uff1aIBM BPM\/ECM\u589e\u52a0AI\u529f\u80fd - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-04-18T13:17:43+00:00\",\"dateModified\":\"2025-04-18T13:17:43+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/14520.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/14520.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/14520.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u90e8\u7f72MCP\u670d\u52a1\u5668\u793a\u4f8b\uff1aIBM BPM\/ECM\u589e\u52a0AI\u529f\u80fd\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u90e8\u7f72MCP\u670d\u52a1\u5668\u793a\u4f8b\uff1aIBM BPM\/ECM\u589e\u52a0AI\u529f\u80fd - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/14520.html","og_locale":"zh_CN","og_type":"article","og_title":"\u90e8\u7f72MCP\u670d\u52a1\u5668\u793a\u4f8b\uff1aIBM BPM\/ECM\u589e\u52a0AI\u529f\u80fd - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.3k\u6b21\uff0c\u70b9\u8d5e35\u6b21\uff0c\u6536\u85cf31\u6b21\u3002MCP Server \u5176\u5b9e\u5c31\u662f\u4e00\u4e2a\u7b26\u5408 MCP \u534f\u8bae\u89c4\u8303 \u7684 Web Server\uff0c\u672c\u8d28\u4e0a\u662f\u4e00\u4e2a\u80fd\u63a5\u6536 JSON \u8bf7\u6c42\u3001\u6309\u9700\u8bbf\u95ee\u672c\u5730\u8d44\u6e90\uff08\u6587\u4ef6\u3001\u6570\u636e\u5e93\u3001API \u7b49\uff09\u5e76\u8fd4\u56de\u7ed3\u679c\u7684 REST API \u670d\u52a1\u3002_mcp pdf\u63d0\u53d6","og_url":"https:\/\/www.wsisp.com\/helps\/14520.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-04-18T13:17:43+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"24 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/14520.html","url":"https:\/\/www.wsisp.com\/helps\/14520.html","name":"\u90e8\u7f72MCP\u670d\u52a1\u5668\u793a\u4f8b\uff1aIBM BPM\/ECM\u589e\u52a0AI\u529f\u80fd - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-04-18T13:17:43+00:00","dateModified":"2025-04-18T13:17:43+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/14520.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/14520.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/14520.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u90e8\u7f72MCP\u670d\u52a1\u5668\u793a\u4f8b\uff1aIBM BPM\/ECM\u589e\u52a0AI\u529f\u80fd"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/14520","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=14520"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/14520\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=14520"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=14520"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=14520"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=14520"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}