MCPF示例
 
MCPF信任框架的真实示例 -在银行、医疗保健、客户服务和供应链领域完成工作实施。
🌟 MCPF的例子是什么?
此存储库包含生产就绪的示例,演示如何在现实场景中使用MCPF信任框架:
Banking Fraud Detection
↓
Fraud Detector Agent
↓ (verify credentials via MCPF-did-vc)
↓ (resolve via MCPF-ans)
↓ (check delegation via MCPF-a2a)
Risk Analyzer Agent
↓
Risk Assessment Result📚 按域举例
🏦 银行与金融
- 欺诈检测链 -委托多代理欺诈分析
- 交易风险评分 -实时风险评估管道
- 反洗钱合规 -反洗钱代理协调
- 信贷决策 -分布式信贷审批工作流程
🏥 医疗保健
- 诊断试剂链 -初级保健→ 专家升级
- 患者记录访问 -隐私保护医疗数据共享
- 处方验证 -多方处方验证
- 临床试验协调 -研究代理协作
💬 客户服务
- L1升级至主管 -自动票路由
- 聊天机器人联盟 -多机器人问题解决
- 知识库共享 -跨代理信息访问
- 情绪分析管道 -多阶段客户分析
📦 供应链
- 货物追踪 -多方物流协调
- 质量控制 -分布式检查工作流程
- 供应商验证 -供应商证书验证
- 清关 -跨境代理协作
🔄 跨域
- 多组织工作流 -银行+医院+保险
- 合规 -多司法管辖区代理协调
- 应急响应 -跨部门危机管理
🚀 快速开始
先决条件
# Clone repository
git clone https://github.com/MCPTrustFramework/MCPF-examples.git
cd MCPF-examples
# Install dependencies (Node.js examples)
cd nodejs/fraud-detection
npm install
# Or Python examples
cd python/fraud-detection
pip install -r requirements.txt
# Or TypeScript examples
cd typescript/fraud-detection
npm install运行示例
# Banking fraud detection (Node.js)
cd nodejs/fraud-detection
node index.js
# Healthcare diagnostic chain (Python)
cd python/diagnostic-chain
python main.py
# Customer service escalation (TypeScript)
cd typescript/service-escalation
npm start📖 示例类别
1.完整的工作流程
使用所有MCPF组件的完整端到端实施。
2.集成模式
具体的集成场景和最佳实践。
3.安全场景
高级安全和信任验证示例。
4.性能优化
高吞吐量和低延迟实现。
🏦 银行业示例:欺诈检测链
脚本: 欺诈检测代理需要将复杂交易委托给风险分析人员。
建筑
┌─────────────────────────┐
│ Transaction Event │
└───────────┬─────────────┘
│
▼
┌─────────────────────────┐
│ Fraud Detector Agent │
│ did:web:bank.example │
│ (MCPF verified) │
└───────────┬─────────────┘
│ 1. Check delegation (A2A)
│ 2. Verify credentials (DID/VC)
│ 3. Resolve target (ANS)
▼
┌─────────────────────────┐
│ Risk Analyzer Agent │
│ did:web:analytics.bank │
│ (MCPF verified) │
└───────────┬─────────────┘
│
▼
┌─────────────────────────┐
│ Risk Assessment │
│ Score + Reasoning │
└─────────────────────────┘实现(TypeScript)
import { MCPF } from 'mcpf-typescript';
async function detectFraud(transaction: Transaction) {
const mcpf = new MCPF({
ansUrl: 'https://ans.veritrust.vc',
a2aUrl: 'https://a2a.bank.example.com'
});
// 1. Resolve both agents
const fraudDetector = await mcpf.ans.resolve({
name: 'fraud-detector.risk.bank.example.agent'
});
const riskAnalyzer = await mcpf.ans.resolve({
name: 'risk-analyzer.analytics.bank.example.agent'
});
// 2. Verify credentials
const detectorValid = await mcpf.did.verifyAgent(fraudDetector.did);
const analyzerValid = await mcpf.did.verifyAgent(riskAnalyzer.did);
if (!detectorValid || !analyzerValid) {
throw new Error('Agent credential verification failed');
}
// 3. Check delegation permission
const delegation = await mcpf.a2a!.checkDelegation({
fromDid: fraudDetector.did,
toDid: riskAnalyzer.did,
action: 'analyze-transaction'
});
if (!delegation.allowed) {
throw new Error(`Delegation denied: ${delegation.reason}`);
}
// 4. Execute risk analysis
const riskScore = await callRiskAnalyzer(
riskAnalyzer.endpoints.agent,
transaction
);
return {
fraudDetectorDid: fraudDetector.did,
riskAnalyzerDid: riskAnalyzer.did,
policyId: delegation.policy?.id,
riskScore: riskScore,
decision: riskScore > 0.7 ? 'BLOCK' : 'ALLOW'
};
}完整示例: 银行/欺诈检测
🏥 医疗保健示例:诊断链
脚本: 初级保健人工智能将复杂病例委托给专业人工智能。
实现(Python)
from mcpf import MCPF
async def diagnostic_workflow(patient_data):
mcpf = MCPF(
ans_url="https://ans.veritrust.vc",
a2a_url="https://a2a.hospital.example.com"
)
# Resolve agents
primary_care = await mcpf.ans.resolve(
"primary-diagnostics.hospital.example.agent"
)
radiology_specialist = await mcpf.ans.resolve(
"radiology-specialist.imaging.hospital.example.agent"
)
# Verify both agents
primary_valid = await mcpf.did.verify_agent(primary_care.did)
specialist_valid = await mcpf.did.verify_agent(radiology_specialist.did)
if not (primary_valid and specialist_valid):
raise Exception("Agent verification failed")
# Check delegation (requires approval for sensitive medical data)
delegation = await mcpf.a2a.check_delegation(
from_did=primary_care.did,
to_did=radiology_specialist.did,
action="analyze-imaging"
)
if not delegation.allowed:
raise Exception(f"Delegation denied: {delegation.reason}")
# Check if approval required
if delegation.policy.constraints.get("requiresApproval"):
# Get human approval
approval = await get_physician_approval(patient_data)
if not approval:
raise Exception("Physician approval denied")
# Execute specialist analysis
diagnosis = await call_specialist(
radiology_specialist.endpoints.agent,
patient_data
)
return {
"primary_care_did": primary_care.did,
"specialist_did": radiology_specialist.did,
"policy_id": delegation.policy.id,
"requires_approval": delegation.policy.constraints.get("requiresApproval"),
"diagnosis": diagnosis
}完整示例: 医疗/诊断链
💬 客户服务示例:升级
脚本: L1聊天机器人在需要时升级为主管AI。
实现(Node.js)
const { MCPF } = require('mcpf-typescript');
async function handleCustomerQuery(query) {
const mcpf = new MCPF({
ansUrl: 'https://ans.veritrust.vc',
a2aUrl: 'https://a2a.company.example.com'
});
// Resolve agents
const chatbotL1 = await mcpf.ans.resolve({
name: 'chatbot-l1.support.company.example.agent'
});
const supervisorAI = await mcpf.ans.resolve({
name: 'supervisor-ai.management.company.example.agent'
});
// Verify credentials
const l1Valid = await mcpf.did.verifyAgent(chatbotL1.did);
const supervisorValid = await mcpf.did.verifyAgent(supervisorAI.did);
if (!l1Valid || !supervisorValid) {
throw new Error('Agent verification failed');
}
// Attempt L1 resolution
const l1Response = await queryL1Chatbot(chatbotL1.endpoints.agent, query);
// Check if escalation needed
if (l1Response.confidence < 0.8 || query.severity === 'high') {
// Check delegation
const delegation = await mcpf.a2a.checkDelegation({
fromDid: chatbotL1.did,
toDid: supervisorAI.did,
action: 'escalate'
});
if (!delegation.allowed) {
return {
status: 'escalation_denied',
reason: delegation.reason,
l1Response: l1Response
};
}
// Check constraints
const { constraints } = delegation.policy;
if (constraints.minimumSeverity &&
query.severity < constraints.minimumSeverity) {
return {
status: 'below_threshold',
l1Response: l1Response
};
}
// Escalate to supervisor
const supervisorResponse = await querySupervisor(
supervisorAI.endpoints.agent,
query,
l1Response
);
return {
status: 'escalated',
l1Did: chatbotL1.did,
supervisorDid: supervisorAI.did,
policyId: delegation.policy.id,
response: supervisorResponse
};
}
return {
status: 'resolved_l1',
response: l1Response
};
}完整示例: 客户服务/升级
📊 所有示例
按语言
| 语言 | 示例 | 状态 |
|---|---|---|
| TypeScript | 8 | ✅ 完成 |
| Python | 8 | ✅ 完成 |
| Node.js | 8 | ✅ 完成 |
按域名
| 领域 | 示例 | 用例 |
|---|---|---|
| 银行业务 | 4 | 欺诈、反洗钱、信贷、风险 |
| 医疗保健 | 4 | 诊断、记录、处方、试验 |
| 客户服务 | 3 | 升级、联盟、情绪 |
| 供应链 | 4 | 跟踪、质量控制、供应商、海关 |
| 跨域 | 3 | 多组织、合规、应急 |
🧪 测试示例
每个示例包括:
- ✅ 完整的工作代码
- ✅ 测试数据/夹具
- ✅ 带安装说明的README
- ✅ 集成测试
- ✅ 性能基准
# Run all tests
npm test
# Run specific domain
npm run test:banking
npm run test:healthcare
# Run integration tests
npm run test:integration
# Benchmark
npm run benchmark📝 文档
每个示例包括:
- README.md -概述、设置、使用
- 建筑.md -系统设计及流程
- 部署.md -生产部署指南
- 安全.md -安全考虑
- API毫米 -API参考
🔧 配置
示例支持多种环境:
# Development
cp .env.example .env.development
npm run dev
# Staging
cp .env.example .env.staging
npm run staging
# Production
cp .env.example .env.production
npm start🤝 贡献
看 贡献.md 用于:
- 添加新示例
- 改进现有示例
- 测试指南
- 文件标准
📝 许可证
MIT许可证-请参阅 许可证
📞 联系
- 网站: https://mcpf.dev
- github: https://github.com/MCPTrustFramework/MCPF-examples
- 问题: https://github.com/MCPTrustFramework/MCPF-examples/issues
- 讨论: https://github.com/MCPTrustFramework/MCPF-examples/discussions
🔗 相关项目
- MCPF规范 -SSOT
- MCPF python -Python SDK
- MCPF字体 -TypeScript SDK
- MCPF安 -代理名称服务
- MCPF注册表 -MCP信托登记处
- MCPF-a2a注册表 -A2A代表团
______________________________________________________________________
版本: 1.0.0-alpha\ 最后更新时间: 2025年12月31日\ 示例: 24个完整实施\ 状态: 生产准备就绪
