77 lines
2.4 KiB
Python
77 lines
2.4 KiB
Python
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
from typing import Any
|
||
|
|
|
||
|
|
WECHAT_MCP_TOOLS: dict[str, dict[str, Any]] = {
|
||
|
|
"wechat-send-message": {
|
||
|
|
"name": "wechat_send_message",
|
||
|
|
"description": "Send a message to a WeChat user or group",
|
||
|
|
"parameters": {
|
||
|
|
"type": "object",
|
||
|
|
"properties": {
|
||
|
|
"target": {"type": "string", "description": "wx:<open_id> or wx:group:<chat_id>"},
|
||
|
|
"content": {"type": "string", "description": "Message content"},
|
||
|
|
},
|
||
|
|
"required": ["target", "content"],
|
||
|
|
},
|
||
|
|
},
|
||
|
|
"wechat-send-media": {
|
||
|
|
"name": "wechat_send_media",
|
||
|
|
"description": "Send media (image/video/voice) to a WeChat user or group",
|
||
|
|
"parameters": {
|
||
|
|
"type": "object",
|
||
|
|
"properties": {
|
||
|
|
"target": {"type": "string"},
|
||
|
|
"media_type": {"type": "string", "enum": ["image", "video", "voice", "file"]},
|
||
|
|
"media_data": {"type": "string", "description": "Base64-encoded media data"},
|
||
|
|
},
|
||
|
|
"required": ["target", "media_type", "media_data"],
|
||
|
|
},
|
||
|
|
},
|
||
|
|
"wechat-read-message": {
|
||
|
|
"name": "wechat_read_message",
|
||
|
|
"description": "Read a message by ID",
|
||
|
|
"parameters": {
|
||
|
|
"type": "object",
|
||
|
|
"properties": {
|
||
|
|
"msg_id": {"type": "string"},
|
||
|
|
},
|
||
|
|
"required": ["msg_id"],
|
||
|
|
},
|
||
|
|
},
|
||
|
|
"wechat-list-peers": {
|
||
|
|
"name": "wechat_list_peers",
|
||
|
|
"description": "List available WeChat contacts",
|
||
|
|
"parameters": {"type": "object", "properties": {}},
|
||
|
|
},
|
||
|
|
"wechat-list-groups": {
|
||
|
|
"name": "wechat_list_groups",
|
||
|
|
"description": "List available WeChat groups",
|
||
|
|
"parameters": {"type": "object", "properties": {}},
|
||
|
|
},
|
||
|
|
}
|
||
|
|
|
||
|
|
WECHAT_MCP_RESOURCES: dict[str, dict[str, Any]] = {
|
||
|
|
"wechat-channel-info": {
|
||
|
|
"uri": "wechat://channel/info",
|
||
|
|
"name": "WeChat Channel Info",
|
||
|
|
"description": "Current WeChat channel configuration and status",
|
||
|
|
},
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
def list_mcp_tools() -> list[dict[str, Any]]:
|
||
|
|
return list(WECHAT_MCP_TOOLS.values())
|
||
|
|
|
||
|
|
|
||
|
|
def list_mcp_resources() -> list[dict[str, Any]]:
|
||
|
|
return list(WECHAT_MCP_RESOURCES.values())
|
||
|
|
|
||
|
|
|
||
|
|
def get_mcp_tool(tool_name: str) -> dict[str, Any] | None:
|
||
|
|
return WECHAT_MCP_TOOLS.get(tool_name)
|
||
|
|
|
||
|
|
|
||
|
|
def get_mcp_resource(resource_uri: str) -> dict[str, Any] | None:
|
||
|
|
return WECHAT_MCP_RESOURCES.get(resource_uri)
|