基于MCP协议的Tablestore实现

表格存储(Tablestore)集成了MCP协议,通过向量和标量的混合检索能力,提供高效的数据存储与检索解决方案。通过本文您可以了解表格存储MCP服务及使用方法。

功能介绍

MCP(Model Context Protocol,模型上下文协议)是一个开放标准协议,旨在通过标准化API连接大型语言模型(LLM)与外部数据源及工具,让AI应用能够高效处理复杂任务。

表格存储的MCP服务提供了以下两个工具:

  • 存储工具(tablestore-store):数据经过Embedding模型(默认为BAAI/bge-base-zh-v1.5)转成向量,连同原文本一起写入到表格存储。

  • 检索工具(tablestore-search):用户的查询文本经过Embedding模型转成向量,检索表格存储的多元索引(使用向量和标量进行混合查询),召回用户期望的结果。

工具实现如下图所示。

image

产品优势

与传统数据库和专用向量数据库相比,表格存储在MCP的场景中有显著的优势:

  • 混合查询:原生支持向量和标量混合查询,其多元索引可以实现任意列的查询(主键列和非主键列)、多字段自由组合查询、地理位置查询、全文检索、模糊查询、嵌套查询、去重、排序、查询数据总行数和统计聚合等丰富的查询能力。

  • 快速落地与全周期支持:提供标准化的API接口/SQL查询,集成LangChain、LlamaIndex、PAI-RAG、LangEngine、LangChain4J、Dify、MCP等第三方开源框架,帮助用户提升开发效率,实现业务价值。

  • 产品生态:支持与阿里云大数据生态无缝对接,如RDS、Flink、MaxCompute等,避免数据孤岛。

  • Serverless:提供Serverless服务,免除软硬件的运维和扩容压力,您可以专注于业务创新和快速迭代。

  • 低成本:按需付费、存储计算分离,无需为闲置资源付费。

  • 弹性扩展:PB级的数据处理能力,支持自动水平分片与弹性资源调度。

准备工作

使用方式

本文以阿里云ECS服务器(Alibaba Cloud Linux 3.2104 LTS 64位操作系统)为例介绍如何运行表格存储MCP服务,并且通过开源工具Cherry Studio使用MCP服务。

如果您希望对源码进行本地调试和二次开发,请下载源码后参见附录2:本地调试和二次开发进行操作。

步骤一:下载源码

  1. 安装Git。如果您使用的服务器已安装Git,请跳过该步骤。

    yum install git
  2. 下载源码。

    git clone https://github.com/aliyun/alibabacloud-tablestore-mcp-server

    如果因为网络问题无法下载,您可以直接下载tablestore-mcp-server,将其上传到服务器后进行解压。解压命令如下:

    tar -zxvf alibabacloud-tablestore-mcp-server-master.tar.gz

步骤二:运行服务

表格存储提供PythonJava两个版本的MCP服务。

Python

Python版本的表格存储MCP服务需要Python3.10及以上版本,并使用uv进行包和环境管理。

Alibaba Cloud Linux 3.2104 LTS 64位系统默认的Python3版本为3.6.8,您可以参照附录1:ECS升级Python升级Python版本。
  1. 进入MCP的源码目录。

    cd alibabacloud-tablestore-mcp-server/tablestore-python-mcp-server
  2. 安装uv。

    pip3 install uv

    关于uv安装的详细信息请参见官方文档

  3. 创建虚拟环境。如果您使用的是其它Python版本,请修改版本号。

    uv venv --python 3.13
  4. 配置环境变量。

    export HF_ENDPOINT=http://hf-mirror.com
    export TABLESTORE_ACCESS_KEY_ID=LTAI********************
    export TABLESTORE_ACCESS_KEY_SECRET=nI9Q**************************
    export TABLESTORE_ENDPOINT=https://d01r********.cn-hangzhou.ots.aliyuncs.com
    export TABLESTORE_INSTANCE_NAME=d01r********

    环境变量说明如下。

    变量名称

    说明

    HF_ENDPOINT

    HuggingFace镜像地址。

    TABLESTORE_ACCESS_KEY_ID

    阿里云账号或RAM用户的AccessKey ID。

    TABLESTORE_ACCESS_KEY_SECRET

    阿里云账号或RAM用户的AccessKey Secret。

    TABLESTORE_ENDPOINT

    表格存储实例的访问地址Endpoint。如果您使用的是ECS,请根据地域情况选择访问地址:

    • ECS与表格存储在同一地域:选择公网地址或者VPC地址。

    • ECS与表格存储不在同一地域:选择公网地址。

    重要

    表格存储新创建的实例默认不开启公网访问,如果您需要使用公网访问地址,请在表格存储控制台实例管理网络管理页签中允许网络类型选中公网,并单击设置保存配置。

    TABLESTORE_INSTANCE_NAME

    表格存储实例的名称。

    其它可选的环境变量

    变量名称

    说明

    SERVER_PORT

    服务运行的端口,默认值为8001。

    TABLESTORE_TABLE_NAME

    表格存储的数据表名称,默认值为ts_mcp_server_py_v1。

    TABLESTORE_INDEX_NAME

    表格存储数据表的多元索引名称,默认值为ts_mcp_server_py_index_v1。

    TABLESTORE_VECTOR_DIMENSION

    向量维度,默认为768。向量维度需要与Embedding模型的向量维度保持一致。

    TABLESTORE_TEXT_FIELD

    文本字段名称,默认值为_content。

    TABLESTORE_VECTOR_FIELD

    向量字段名称,默认值为_embedding。

    EMBEDDING_PROVIDER_TYPE

    Embedding模型提供者,目前只支持hugging_face。

    EMBEDDING_MODEL_NAME

    Embedding模型名称,默认值为BAAI/bge-base-zh-v1.5。Embedding模型的向量维度需要与TABLESTORE_VECTOR_DIMENSION保持一致。

    TOOL_STORE_DESCRIPTION

    写入工具的描述信息。

    TOOL_SEARCH_DESCRIPTION

    检索工具的描述信息。

  5. 运行MCP服务。

    uv run tablestore-mcp-server

    初次运行需要下载依赖,请您耐心等待。如果因为网络问题导致下载中断,重新执行命令即可。运行成功后,会打印如下日志。

    INFO:tablestore_mcp_server.server:mcp host:0.0.0.0, port:8001
    INFO:root:run tablestore-mcp-server by: sse

Java

运行表格存储MCP服务需要JDK17版本。

  1. 安装JDK。

    yum -y install java-17-openjdk-devel.x86_64
  2. 进入MCP的源码目录。

    cd alibabacloud-tablestore-mcp-server/tablestore-java-mcp-server
  3. 编译源码。

    ./mvnw package -DskipTests -s settings.xml

    编译成功后,会打印如下日志。

    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time:  01:58 min
    [INFO] Finished at: 2025-03-26T11:31:21+08:00
    [INFO] ------------------------------------------------------------------------
  4. 配置环境变量。

    export HF_ENDPOINT=http://hf-mirror.com
    export TABLESTORE_ACCESS_KEY_ID=LTAI********************
    export TABLESTORE_ACCESS_KEY_SECRET=nI9Q**************************
    export TABLESTORE_ENDPOINT=https://d01r********.cn-hangzhou.ots.aliyuncs.com
    export TABLESTORE_INSTANCE_NAME=d01r********

    环境变量说明如下。

    变量名称

    说明

    HF_ENDPOINT

    HuggingFace镜像地址。

    TABLESTORE_ACCESS_KEY_ID

    阿里云账号或RAM用户的AccessKey ID。

    TABLESTORE_ACCESS_KEY_SECRET

    阿里云账号或RAM用户的AccessKey Secret。

    TABLESTORE_ENDPOINT

    表格存储实例的访问地址Endpoint。如果您使用的是ECS,请根据地域情况选择访问地址:

    • ECS与表格存储在同一地域:选择公网地址或者VPC地址。

    • ECS与表格存储不在同一地域:选择公网地址。

    重要

    表格存储新创建的实例默认不开启公网访问,如果您需要使用公网访问地址,请在表格存储控制台实例管理网络管理页签中允许网络类型选中公网,并单击设置保存配置。

    TABLESTORE_INSTANCE_NAME

    表格存储实例的名称。

    其它可选的环境变量

    变量名称

    说明

    SERVER_PORT

    服务运行的端口,默认值为8080。

    TABLESTORE_TABLE_NAME

    表格存储的数据表名称,默认值为tablestore_java_mcp_server_v1。

    TABLESTORE_INDEX_NAME

    表格存储数据表的多元索引名称,默认值为tablestore_java_mcp_server_index_v1。

    TABLESTORE_TABLE_PK_NAME

    表格存储数据表的主键名称,默认值为id。

    TABLESTORE_VECTOR_DIMENSION

    向量维度。默认为768。向量维度需要与Embedding模型的向量维度保持一致。

    TABLESTORE_TEXT_FIELD

    文本字段名称,默认值为_content。

    TABLESTORE_VECTOR_FIELD

    向量字段名称,默认值为_embedding。

    EMBEDDING_MODEL_NAME

    Embedding模型名称,默认值为ai.djl.huggingface.rust/BAAI/bge-base-en-v1.5/0.0.1/bge-base-en-v1.5。Embedding模型的向量维度需要与TABLESTORE_VECTOR_DIMENSION保持一致。

  5. 运行MCP服务。

    java -jar target/tablestore-java-mcp-server-1.0-SNAPSHOT.jar

    运行成功后,会打印如下日志。

    2025-03-26T11:35:31.329+08:00  INFO 5116 --- [           main] o.s.a.a.m.s.MpcServerAutoConfiguration   : Registered tools2 notification: true
    2025-03-26T11:35:31.519+08:00  INFO 5116 --- [           main] o.s.b.web.embedded.netty.NettyWebServer  : Netty started on port 8080 (http)
    2025-03-26T11:35:31.534+08:00  INFO 5116 --- [           main] c.a.openservices.tablestore.sample.App   : Started App in 44.143 seconds (process running for 44.766)

步骤三:使用MCP服务

  1. 前往Cherry Studio官网下载并安装客户端。

  2. 单击左下角的设置按钮,设置模型服务、默认模型和MCP服务器。

    1. 模型服务:Cherry Studio内置了非常多的模型服务商,您可以根据自己的需要选择模型服务商,获取服务商的API密钥并在模型服务中填写密钥以及管理模型。本文使用的阿里云百炼的qwen-max模型,使用前需要获取API Key

    2. 默认模型:设置默认模型,您也可以在对话页面选择模型。

      image

    3. MCP服务器:单击添加服务器,名称和描述可以自定义,类型选择SSE,URL的格式为 http://server_ip:port/sse,Python默认的端口为8001,Java默认的端口为8080。首次进入MCP服务器设置页面还需要按照提示安装UVBun。

      重要

      如果您使用的是ECS,需要添加安全组规则,在入方向规则中添加自定义TCP端口的允许访问策略,访问目的端口为MCP服务运行的端口。

      image

  3. 在对话页面选择MCP服务器。

    image

  4. 与助手进行对话,将文档写入到表格存储中。

    image

    您可以在服务器中查看MCP调用日志。

    INFO:mcp.server.lowlevel.server:Processing request of type ListToolsRequest
    INFO:mcp.server.lowlevel.server:Processing request of type CallToolRequest
    Batches: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00,  1.62it/s]
    INFO:tablestore_mcp_server.tablestore_connector:Storing Node ID: d6d627d4-335b-426e-bbf1-54646ad6b375
    Text: 阿里云ECS提供了多种基础计费方式,主要包括以下几种:  1.
    按量付费:用户根据实际使用的计算资源按小时支付费用。这种方式适合业务量波动较大的场景。 2.
    包年包月:用户预先购买一段时间的计算资源使用权,如一个月或一年等。适用于业务稳定且可以预测的情况。 3.
    预留实例券(RI):用户通过承诺使用一定时间长度来换取折扣价,从而降低长期使用成本。 4.
    抢占式实例:利用阿里云闲置资源提供的一种低成本选择,价格极低但可能会因为供需变化而被系统自动释放。 5.
    储蓄计划:为长期稳定运行的工作负载设计的计费模式,通过提前支付部分费用来获得更高的折扣。
    每种计费方式都有其特点和适用场景,用户可以根据自身需求选择合适的方案。

    您也可以在表格存储控制台查看写入的数据。

    image

  5. 与助手进行会话,检索表格存储中的相关文档。

    image

    服务器可以查看MCP调用日志。

    INFO:mcp.server.lowlevel.server:Processing request of type ListToolsRequest
    INFO:mcp.server.lowlevel.server:Processing request of type CallToolRequest
    INFO:tablestore_mcp_server.tablestore_connector:Search query: ECS计费模式, size: 2
    Batches: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00,  6.44it/s]
    INFO:llama_index.vector_stores.tablestore.base:Tablestore search successfully. request_id:00063136-2eb3-b3a9-9009-db0a85e96694

相关文档

附录

附录1:ECS升级Python

本文以Python3.13.2为例为您介绍如何升级Python版本。

  1. 下载Python。

    wget https://www.python.org/ftp/python/3.13.2/Python-3.13.2.tgz

    如果因为网络问题无法下载,您可以直接下载Python-3.13.2,并将其上传到服务器。

  2. 解压文件。

    tar -zxvf Python-3.13.2.tgz
  3. 安装依赖。

    yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel xz-devel libffi-devel libuuid-devel libtirpc-devel libnsl2-devel
  4. 进入Python目录。

    cd Python-3.13.2
  5. 配置安装路径。

    ./configure
  6. 编译Python。

    make
  7. 安装Python。

    make install
  8. 查看已安装的版本。

    1. 查看Python版本。

      python3 --version
    2. 查看Pip版本。

      pip3 --version

附录2:本地调试和二次开发

您可以在本地IDE运行MCP源码,并使用MCP Inspector工具进行调试。运行代码前,需要先配置系统环境变量。

Windows

以管理员身份运行命令提示符,执行以下命令。

# 配置 AccessKey ID
setx TABLESTORE_ACCESS_KEY_ID LTAI******************** /m
# 配置 AccessKey Secret
setx TABLESTORE_ACCESS_KEY_SECRET nI9Q************************** /m
# 配置实例访问地址 Endpoint
setx TABLESTORE_ENDPOINT https://d01r********.cn-hangzhou.ots.aliyuncs.com /m
# 配置实例名称
setx TABLESTORE_INSTANCE_NAME d01r******** /m
macOS/Linux/Unix
# 配置 AccessKey ID
export TABLESTORE_ACCESS_KEY_ID=LTAI********************
# 配置 AccessKey Secret
export TABLESTORE_ACCESS_KEY_SECRET=nI9Q**************************
# 配置实例访问地址 Endpoint
export TABLESTORE_ENDPOINT=https://d01r********.cn-hangzhou.ots.aliyuncs.com
# 配置实例名称
export TABLESTORE_INSTANCE_NAME=d01r********

2.1 运行源码

Python

本地运行MCP源码的环境要求:

  • Python 3.10及以上版本。

  • PyCharm 2024.3.2及以上版本。

  • PyCharm配置uv环境

完成环境配置后,您需要在PyCharm中打开MCP的源码目录 tablestore-python-mcp-server,并运行 src/tablestore_mcp_server/main.py 文件。运行成功后,控制台会打印如下日志。

D:\Projects\Python\tablestore-python-mcp-server\.venv\Scripts\python.exe D:\Projects\Python\tablestore-python-mcp-server\src\tablestore_mcp_server\main.py 
INFO:tablestore_mcp_server.embedding.provider:Using embedding provider EmbeddingProviderType.HUGGING_FACE with model BAAI/bge-base-zh-v1.5
INFO:sentence_transformers.SentenceTransformer:Load pretrained SentenceTransformer: BAAI/bge-base-zh-v1.5
INFO:sentence_transformers.SentenceTransformer:2 prompts are loaded, with the keys: ['query', 'text']
INFO:tablestore_mcp_server.tablestore_connector:parameters:
            instance_name=d01r4xig5k9c
            table_name=ts_mcp_server_py_v1
            index_name=ts_mcp_server_py_index_v1
            vector_dimension=768
            text_field=_content
            vector_field=_embedding
            
Batches: 100%|██████████| 1/1 [00:00<00:00, 16.84it/s]
INFO:llama_index.vector_stores.tablestore.base:Tablestore system table[ts_mcp_server_py_v1] already exists
INFO:llama_index.vector_stores.tablestore.base:Tablestore system index[ts_mcp_server_py_index_v1] already exists
INFO:tablestore_mcp_server.server:mcp host:0.0.0.0, port:8001
INFO:root:run tablestore-mcp-server by: sse

Java

本地运行MCP源码的环境要求:JDK17

完成环境配置后,您需要在IDEA中打开MCP的源码目录 tablestore-java-mcp-server,并运行 src/main/java/com.alicloud.openservices.tablestore.sample/App.java 文件。运行成功后,控制台会打印如下日志。

C:\Users\KitKat\.jdks\corretto-17.0.14\bin\java.exe ...

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/

 :: Spring Boot ::                (v3.4.3)

2025-03-31T16:49:31.460+08:00  INFO 27160 --- [           main] c.a.openservices.tablestore.sample.App   : Starting App using Java 17.0.14 with PID 27160 (D:\Projects\IdeaProjects\tablestore-java-mcp-server\target\classes started by KitKat in D:\Projects\IdeaProjects\tablestore-java-mcp-server)
2025-03-31T16:49:31.463+08:00  INFO 27160 --- [           main] c.a.openservices.tablestore.sample.App   : No active profile set, falling back to 1 default profile: "default"
2025-03-31T16:49:32.567+08:00  INFO 27160 --- [           main] c.a.o.t.sample.service.EmbeddingService  : use embedding model:ai.djl.huggingface.rust/BAAI/bge-base-en-v1.5/0.0.1/bge-base-en-v1.5
2025-03-31T16:49:32.593+08:00 DEBUG 27160 --- [           main] ai.djl.engine.Engine                     : Registering EngineProvider: Rust
2025-03-31T16:49:32.595+08:00 DEBUG 27160 --- [           main] ai.djl.engine.Engine                     : Registering EngineProvider: PyTorch
2025-03-31T16:49:32.596+08:00 DEBUG 27160 --- [           main] ai.djl.engine.Engine                     : Registering EngineProvider: OnnxRuntime
2025-03-31T16:49:32.598+08:00 DEBUG 27160 --- [           main] ai.djl.engine.Engine                     : Found default engine: PyTorch
2025-03-31T16:49:41.428+08:00 DEBUG 27160 --- [           main] ai.djl.repository.zoo.DefaultModelZoo    : Scanning models in repo: class ai.djl.repository.RemoteRepository, djl://ai.djl.huggingface.rust/BAAI/bge-base-en-v1.5/0.0.1/bge-base-en-v1.5
2025-03-31T16:49:41.430+08:00 DEBUG 27160 --- [           main] ai.djl.repository.zoo.ModelZoo           : Loading model with Criteria:
	Application: UNDEFINED
	Input: class java.lang.String
	Output: class [F
	ModelZoo: ai.djl.localmodelzoo

2025-03-31T16:49:41.431+08:00 DEBUG 27160 --- [           main] ai.djl.repository.zoo.ModelZoo           : Searching model in specified model zoo: ai.djl.localmodelzoo
2025-03-31T16:49:41.431+08:00 DEBUG 27160 --- [           main] ai.djl.repository.zoo.ModelZoo           : Checking ModelLoader: ai.djl.huggingface.rust:BAAI/bge-base-en-v1.5 NLP.TEXT_EMBEDDING [
	ai.djl.huggingface.rust/BAAI/bge-base-en-v1.5/0.0.1/bge-base-en-v1.5 {"en":"true"}
]
2025-03-31T16:49:41.540+08:00 DEBUG 27160 --- [           main] ai.djl.repository.MRL                    : Preparing artifact: djl://ai.djl.huggingface.rust/BAAI/bge-base-en-v1.5/0.0.1/bge-base-en-v1.5, ai.djl.huggingface.rust/BAAI/bge-base-en-v1.5/0.0.1/bge-base-en-v1.5 {"en":"true"}
2025-03-31T16:49:41.543+08:00 DEBUG 27160 --- [           main] ai.djl.repository.AbstractRepository     : Items to download: 1
2025-03-31T16:49:41.543+08:00 DEBUG 27160 --- [           main] ai.djl.repository.AbstractRepository     : Downloading artifact: https://mlrepo.djl.ai/model/nlp/text_embedding/ai/djl/huggingface/rust/BAAI/bge-base-en-v1.5/0.0.1/bge-base-en-v1.5.zip ...
Downloading: 100% |========================================|
Loading:     100% |========================================|
2025-03-31T16:50:48.835+08:00  INFO 27160 --- [           main] ai.djl.util.Platform                     : Found matching platform from: jar:file:/C:/Users/KitKat/.m2/repository/ai/djl/huggingface/tokenizers/0.32.0/tokenizers-0.32.0.jar!/native/lib/tokenizers.properties
2025-03-31T16:50:48.836+08:00 DEBUG 27160 --- [           main] a.d.huggingface.tokenizers.jni.LibUtils  : Using cache dir: C:\Users\KitKat\.djl.ai\tokenizers\0.21.0-0.32.0-cpu-win-x86_64
2025-03-31T16:50:48.837+08:00  INFO 27160 --- [           main] a.d.huggingface.tokenizers.jni.LibUtils  : Extracting native/lib/win-x86_64/cpu/libwinpthread-1.dll to cache ...
2025-03-31T16:50:48.844+08:00  INFO 27160 --- [           main] a.d.huggingface.tokenizers.jni.LibUtils  : Extracting native/lib/win-x86_64/cpu/libgcc_s_seh-1.dll to cache ...
2025-03-31T16:50:48.852+08:00  INFO 27160 --- [           main] a.d.huggingface.tokenizers.jni.LibUtils  : Extracting native/lib/win-x86_64/cpu/libstdc++-6.dll to cache ...
2025-03-31T16:50:48.869+08:00  INFO 27160 --- [           main] a.d.huggingface.tokenizers.jni.LibUtils  : Extracting native/lib/win-x86_64/cpu/tokenizers.dll to cache ...
2025-03-31T16:50:48.961+08:00 DEBUG 27160 --- [           main] a.d.huggingface.tokenizers.jni.LibUtils  : Loading huggingface library from: C:\Users\KitKat\.djl.ai\tokenizers\0.21.0-0.32.0-cpu-win-x86_64
2025-03-31T16:50:48.962+08:00 DEBUG 27160 --- [           main] a.d.huggingface.tokenizers.jni.LibUtils  : Loading native library: C:\Users\KitKat\.djl.ai\tokenizers\0.21.0-0.32.0-cpu-win-x86_64\libwinpthread-1.dll
2025-03-31T16:50:48.969+08:00 DEBUG 27160 --- [           main] a.d.huggingface.tokenizers.jni.LibUtils  : Loading native library: C:\Users\KitKat\.djl.ai\tokenizers\0.21.0-0.32.0-cpu-win-x86_64\libgcc_s_seh-1.dll
2025-03-31T16:50:48.977+08:00 DEBUG 27160 --- [           main] a.d.huggingface.tokenizers.jni.LibUtils  : Loading native library: C:\Users\KitKat\.djl.ai\tokenizers\0.21.0-0.32.0-cpu-win-x86_64\libstdc++-6.dll
2025-03-31T16:50:48.992+08:00 DEBUG 27160 --- [           main] a.d.huggingface.tokenizers.jni.LibUtils  : Loading native library: C:\Users\KitKat\.djl.ai\tokenizers\0.21.0-0.32.0-cpu-win-x86_64\tokenizers.dll
2025-03-31T16:50:49.806+08:00  INFO 27160 --- [           main] c.a.o.t.s.service.TablestoreService      : table:tablestore_java_mcp_server_v1 already exists
2025-03-31T16:50:49.875+08:00  INFO 27160 --- [           main] c.a.o.t.s.service.TablestoreService      : index:tablestore_java_mcp_server_index_v1 already exists
2025-03-31T16:50:50.388+08:00  INFO 27160 --- [           main] o.s.a.a.m.s.MpcServerAutoConfiguration   : Registered tools2 notification: true
2025-03-31T16:50:50.582+08:00  INFO 27160 --- [           main] o.s.b.web.embedded.netty.NettyWebServer  : Netty started on port 8080 (http)
2025-03-31T16:50:50.594+08:00  INFO 27160 --- [           main] c.a.openservices.tablestore.sample.App   : Started App in 79.764 seconds (process running for 80.524)

2.2 工具调试

  1. 安装Node.js

  2. 在终端工具中执行以下命令,根据提示输入 y,运行MCP Inspector。

    npx @modelcontextprotocol/inspector node build/index.js

    初次运行需要下载工具,请等待一段时间。运行成功后,终端会打印以下内容。

    PS C:\Users\KitKat> npx @modelcontextprotocol/inspector node build/index.js
    Need to install the following packages:
    @modelcontextprotocol/inspector@0.7.0
    Ok to proceed? (y) y
    
    Starting MCP inspector...
    Proxy server listening on port 3000
    
    MCP Inspector is up and running at http://localhost:5173
  3. 根据提示,在浏览器中打开http://localhost:5173,访问Inspector。然后根据本地运行情况选择传输类型并填写URL,单击Connect,连接MCP服务。

    image

    您可以单击List Tools,查看可调试的工具。

    image

  4. 选择store工具,在content中输入内容,单击Run Tool,向表格存储中写入数据。

    image

    您可以在IDE控制台查看日志,或者登录表格存储控制台查看数据。

    image

  5. 选择search工具,在query中输入查询内容和size(返回的数据条目),单击Run Tool,查询表格存储中的数据。

    image