python实现封装coze的插件为sse的mcp服务代码
代码语言:python
所属分类:其他
代码描述:python实现封装coze的插件为sse的mcp服务代码,我们以coze换脸插件为例封装成mcp服务,可以在cursor中调用。教程:https://blog.bfw.wiki/user12308/17452908752995400080.html
代码标签: python 封装 coze 插件 sse mcp 服务 代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
#!/usr/local/python3/bin/python3
# -*- coding: utf-8 -*
#!/usr/local/python3/bin/python3
# -*- coding: utf-8 -*
#完整教程:https://blog.bfw.wiki/user12308/17452908752995400080.html
from typing import Any
import httpx
import requests
import json
import time
from mcp.server.fastmcp import FastMCP
# Initialize FastMCP server
mcp = FastMCP("swapface")
USER_AGENT = "app/1.0"
COZE_APIKEY = "pat_y" # 替换为你的实际 API Key
# 发起对话
def start_chat(msg):
url = 'https://api.coze.cn/v3/chat'
headers = {
'Authorization': 'Bearer ' + COZE_APIKEY,
'Content-Type': 'application/json'
}
data = {
"bot_id": "botid",
"user_id": "1231",
"stream": False,
"auto_save_history": True,
"additional_messages": [
{
"role": "user&quo.........完整代码请登录后点击上方下载按钮下载查看















网友评论0