当前位置: 首页 > news >正文

mcpo的简单使用

1.安装依赖

conda create -n mcpo python=3.11
conda activate mcpo
pip install mcpo pip install uv

2.随便从https://github.com/modelcontextprotocol/servers?tab=readme-ov-file

找一个mcp服务使用就行,我这里选的是爬虫

然后安装

pip install mcp-server-fetch

3.然后我们运行

uvx mcpo --port 8000 -- uvx mcp-server-fetch

4.此时在浏览器打开

http://localhost:8000/docs

就可以看到接口文档了

然后写个py脚本测试一下

import requests
import jsondef fetch_webpage(url, max_length=10000, start_index=0, raw=False):"""Fetch content from a URL using the MCP Fetch server.Args:url (str): The URL to fetchmax_length (int): Maximum number of characters to returnstart_index (int): Start content from this character indexraw (bool): Get raw HTML content without markdown conversionReturns:dict: The response from the server containing the fetched content"""try:# Make a POST request to the fetch endpointresponse = requests.post("http://localhost:8000/fetch",json={"url": url,"max_length": max_length,"start_index": start_index,"raw": raw})# Ensure the request was successfulresponse.raise_for_status()# Parse the responsereturn response.json()except Exception as e:return {"error": str(e)}# Example usage
if __name__ == "__main__":# Fetch the specific URL you requestedtarget_url = "https://docs.cline.bot"result = fetch_webpage(target_url)print(result)

over

mcpo出现的意义非常好,节省了我们配置的时间,从此,我们就可以像访问接口一样使用mcp服务了

5.通过配置文件启动多个mcp服务同时

mcpo.json


{"mcpServers": {"fetch": {"command": "uvx","args": ["mcp-server-fetch"]},"time": {"command": "uvx","args": ["mcp-server-time", "--local-timezone=Asia/Shanghai"]}}}

执行下面的命令

uvx mcpo --config mcpo.json --port 8000 --api-key "your-secret-key"

 对应接口文档如下所示

相关文章:

  • .NET仓储层在 using 块中创建 SqlSugarClient 的风险
  • 射频系统级芯片集成技术研究
  • echarts模板化开发,简易版配置大屏组件-根据配置文件输出图形和模板(vue2+echarts5.0)
  • Vue 3 Watch 监听 Props 的踩坑记录
  • Git常用操作命令
  • Qt 下载的地址集合
  • 【Maven】配置文件
  • audio 核心服务AudioPolicyService 和AudioFlinger启动流程
  • jsconfig.json文件的作用
  • 【SAP-CO】生产的成本流转和成本分析
  • Spark-Streaming
  • 【深度学习新浪潮】新视角生成的研究进展调研报告(2025年4月)
  • 软件测试之接口测试常见面试
  • 第48讲:空间大数据与智慧农业——时空大数据分析与农业物联网的融合实践
  • ecovadis评级范围,如何拿到ecovadis评级高分
  • 局域网内,将linux(Ubuntu)的硬盘映射成Windows上,像本地磁盘一样使用
  • 健康生活新指南
  • ESM 内功心法:化解 require 中的夺命一击!
  • Spring 中 @Component, @Repository, @Service 的区别及示例代码
  • 学习Docker遇到的问题
  • 神二十6个半小时到站
  • 著名水声学家陆佶人逝世,曾参加我国第一代核潜艇主动声纳研制
  • A股三大股指涨跌互现:黄金股再度走强,两市成交10900亿元
  • 史蒂夫·麦奎因透露罹患前列腺癌,呼吁同胞莫受困于男性气概
  • 解除近70家煤电厂有毒物质排放限制,特朗普能重振煤炭吗?
  • 梅德韦杰夫:如果欧盟和美国 “撒手不管”,俄罗斯会更快解决俄乌冲突