关于 MCP Server – Affinidi Elements API
MCP Server – Affinidi Elements API 是一个通过 Affinidi TDK 访问 Affinidi Elements API 的 TypeScript 服务,展示 MCP 资源、工具和提示词,并支持查询项目与登录配置、签发活动门票凭证。
主要功能
- 01列出 Affinidi 项目
- 02列出项目登录配置
- 03签发活动门票凭证
- 04展示 MCP 资源、工具和提示词
适用场景
- 01查询项目及其登录配置
- 02签发可验证的活动门票凭证
MCP 相关
该服务将 Affinidi Elements API 操作作为 MCP 工具提供,并演示面向笔记的资源和提示词。配套聊天应用可连接服务,通过自然语言调用工具。
配置
远程服务无需本地安装。选择你使用的客户端,复制配置或使用一键安装。
服务地址
http://localhost:3002/mcp一键复制安装命令
Claude CodeTerminal
claude mcp add --transport http affinidi-elements http://localhost:3002/mcpCursor.cursor/mcp.json
{"mcpServers":{"affinidi-elements":{"type":"http","url":"http://localhost:3002/mcp"}}}在 Cursor 中打开VS Code.vscode/mcp.json
{"servers":{"affinidi-elements":{"type":"http","url":"http://localhost:3002/mcp"}}}在 VS Code 中打开Claude Desktopclaude_desktop_config.json
{"mcpServers":{"affinidi-elements":{"type":"http","url":"http://localhost:3002/mcp"}}}Windsurf~/.codeium/windsurf/mcp_config.json
{"mcpServers":{"affinidi-elements":{"serverUrl":"http://localhost:3002/mcp"}}}命令在终端中运行;JSON 粘贴到对应客户端的 MCP 配置后重启。需要授权的服务会在首次连接时提示登录。
工具
详细介绍
MCP 服务 – Affinidi Elements API
一个通过 Affinidi TDK 与 Affinidi Elements API 交互的 Model Context Protocol (MCP) 可流式传输 HTTP 服务。
这个基于 TypeScript 的服务展示了如何构建一个简单的笔记系统,同时演示 MCP 的核心概念,例如:
- 资源:使用 URI 和元数据表示文本笔记
- 工具:支持创建或列出数据等交互
- 提示词:支持动态生成内容,例如笔记摘要
🚀 功能
🛠️ 工具
list_project– 获取在 Affinidi 中创建的项目列表list_login_configurations– 获取项目中的所有登录配置vc_issuance_event_ticket– 为活动门票签发可验证凭证(VC)
🧑💻 开发
1. 安装依赖
npm install
2. 运行服务
npm run dev
💬 聊天应用集成
配套的聊天应用会连接到此 MCP 服务,并动态调用工具,让用户能够通过自然语言输入执行列出项目或签发凭证等操作。
仓库链接:https://github.com/kamarthiparamesh/affinidi-ai-chat-bot
待办事项
- 将 OpenAPI 规范转换为工具定义,以便将所有 API 转换为工具定义
使用示例 MCP 客户端进行测试
- 在新的终端中运行 MCP 服务
npm run dev
- 在新的终端中运行 MCP 客户端
npm run test
示例输出
affinidi-elements-mcp-server % npm run test
> [email protected] test
> npx tsx src/affinidi-test-client.ts
MCP Interactive Client
=====================
Connecting to http://localhost:3002/mcp...
Transport created with session ID: 92ba5c09-ccfc-4218-bb1a-de32ca6728b5
Connected to MCP server
Available commands:
connect [url] - Connect to MCP server (default: http://localhost:3000/mcp)
disconnect - Disconnect from server
terminate-session - Terminate the current session
reconnect - Reconnect to the server
list-tools - List available tools
call-tool <name> [args] - Call a tool with optional JSON arguments
list-project <uat> - Call the list projects tool by passing user access token
list-login-config <pst> - Call the list projects tool by passing project scope token
list-prompts - List available prompts
get-prompt [name] [args] - Get a prompt with optional JSON arguments
list-resources - List available resources
read-resource [id] - Read resource
help - Show this help
quit - Exit the program
> list-tools
Available tools:
- list_project: Get the list of projects created in affinidi
- list_login_configurations: List all the Login Configurations in the default Project
- vc_issuance_event_ticket: Issue a verifiable credential (VC) for an event ticket. Use this tool when a user requests a ticket or VC for an event (e.g., "I want a ticket VC for Tech Event in Bangalore tomorrow"). On success, it returns a VC offer URL for the user to claim the ticket.
> list-project <YOUR USER ACCESS TOKEN>
Calling tool 'list_project' with args: {
apiKey: 'eyJh...'
}
Tool result:
List of projects => [{"id":"0be8df01-6099-4e1e-bcb6-2dc3562d72fd","name":"Test Project","description":"","createdAt":"2024-07-16T12:07:07.805Z","updatedAt":"2024-07-16T12:07:07.805Z","ownerId":"user/349f037d-c10c-4e81-a168-1222333"}]
> list-login-config <YOUR PROJECT SCOPE TOKEN>
Calling tool 'list_login_configurations' with args: {
apiKey: 'ey....'
}
Tool result:
List of Login Configurations => [{"ari":"ari:identity:ap-southeast-1:801a212a-90b1-4463-bfb3-5235181d477d:login_configuration/3b1433f3-1886-4a34-9072-7130ef3c3fbb","projectId":"801a212a-90b1-4463-bfb3-5235181d477d","configurationId":"3b1433f3-1886-4a34-9072-7130ef3c3fbb","name":"Eventi","redirectUris":["http://localhost:3000/api/auth/callback/affinidi"],"auth":{"clientId":"5619f48e-bca8-4529-ace3-96ebaafc2f04","issuer":"https://801a212a-90b1-4463-bfb3-5235181d477d.apse1.login.affinidi.io"},"tokenEndpointAuthMethod":"client_secret_post","description":"description#733123","createdAt":"2024-09-17T10:17:08.755Z","modifiedAt":"2024-09-17T10:17:08.755Z","createdBy":"user/349f037d-c10c-4e81-a168-f1b273c287e3","modifiedBy":"user/349f037d-c10c-4e81-a168-f1b273c287e3","creationDate":"2024-09-17T10:17:09Z","failOnMappingConflict":true,"clientMetadata":{"name":"Eventi","logo":"https://login.affinidi.com/default-client-logo.svg","domainVerified":false,"origin":"http://localhost:3000"}}]
> isssue-event-vc <YOUR PROJECT SCOPE TOKEN> <YOUR PROJECT ID>
Calling tool 'vc_issuance_event_ticket' with args: {
apiKey: 'eyJ0eX...',
project_id: '801a212a-90b1-4463-bfb3-5235181d477d',
given_name: 'paramesh',
last_name: 'kamarthi',
email: '[email protected]',
event_name: 'MCP Event',
location: 'Banglore',
ticket_type: 'regular',
event_date: '2025-10-01'
}
Tool result:
**Event ticket VC offer ready to claim!**
Click the link below and enter the transaction code to complete the process:
🔗 [Claim your Event Ticket VC](https://vault.affinidi.com/claim?credential_offer_uri=https://801a212a-90b1-4463-bfb3-5235181d477d.apse1.issuance.affinidi.io/offers/d620285d-a993-4ae5-a969-c3861ecbd414)
🔒 **Transaction Code:** `539848`
评论
支持 Markdown
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。