MCP ExplorerExplorer

Mcp Dev Test01

@huangyixin447on 9 months ago
4 MIT
FreeCommunity
AI Systems
# MCP Related Development Specifications

Overview

What is Mcp Dev Test01

MCP_dev_Test01 is a project designed to encapsulate the development specifications for MCP, simplifying and structuring the development process.

Use cases

Use cases include developing tools for database operations, creating context-specific prompts for user interactions, and configuring services for various environments using the unified configuration module.

How to use

To use MCP_dev_Test01, create your own tools or prompts by inheriting from the provided base classes (base_Mcp_Handles.py for tools and base_Prompt.py for prompts) and overriding the necessary methods to register them automatically.

Key features

Key features include a structured approach to tool and prompt development, a unified configuration module for database settings, and the ability to build an MCP service using server.py with different implementations for SSE or STDIO.

Where to use

MCP_dev_Test01 can be used in software development projects that require structured tool and prompt management, particularly in scenarios involving database interactions and automated responses.

Content

MCP_dev项目说明

此项目目的在为MCP的开发进行封装,用以简化,结构化MCP的开发流程

首先mcp的开发大致分为两类:

1.MCP的工具类开发,用于执行核心工具逻辑base_Mcp_Handles.py:

在本项目的基类中,将所有的工具放入list容器中,并且对于MCP规范所必须的
run_tool get_tool_description 方法做了接口规范,强制子类继承

工具基类如下:

在这个文件所在的python包下,直接新建你要创建的工具,例如操作mysql,操作邮件服务器发邮件 的python类,并且继承这个类,重写其中两个类属性,以及get_tool_description run_tool 方法即可自动进行注册。实现逻辑并且按照这两个方法的要求返回参数即可。

2.MCP的提示词开发模块

对于不同情景下问题要有不同的提示词,每一种场景的提示词的逻辑与刚刚的1的工具模块的逻辑差不多, 也存在一个基类base_Prompt.py,具体封装的方式见源码, 使用的方法同样是去继承

BasePrompt类,并且重写属性

image.png

以及重写以下两个方法

image.png

即可完成自动注册

3.此外还有一个统一配置的模块

config下的dbconfig.py

新建一个.env 文件, 并且复制路径

修改以下的路径为你自己的路径

image.png

.env填写的示范例子如下

# MySQL数据库配置
mysql_host=localhost
mysql_port=11801
mysql_user=root
mysql_password=123456
mysql_database=MCP_taobao
# 可选值: readonly, writer, admin,默认为 readonly
mysql_role=readonly

当然其他配置也行,都可以被dbconfig读取

具体看源码的示例

4.实际构建mcp服务的server.py

将以上各种封装好的,tool,prompt交给mcp的server,并且sse或者stdio的server不一样,要采用不同的方式实现。具体见源码。

Tools

No tools

Comments

Recommend MCP Servers

View All MCP Servers