96SEO 2026-02-19 10:16 7
id="content_views">
MCP

够以结构化的⽅式与外部⼯具和资源进⾏交互。
该协议⽀持多种传输机制,以在不同环境中提供灵活
模型更顺畅⼯作的桥梁和助⼿。
org.springframework.boot spring-boot-starter-web org.springframework.ai spring-ai-starter-model-openai
ai-siliconflow-mcp-glmai:openai:base-url:
https://api.siliconflow.cnapi-key:
sk-rlpneielwjrtbzwghvmtnkrfzsqoorkclubnimumojlptvqzchat:options:model:
class="language-java">@Configuration
openAiChatModel;@Bean("openAiChatClient")public
openAiChatClient(Wea***rJiaService
ChatClient.builder(openAiChatModel).build();}
com.jiazhong.mingxing.ai.siliconflow.mcp.glm.service;
org.springframework.stereotype.Service;
{log.info("开始调用获取当前时间的工具......");SimpleDateFormat
class="language-java">@Configuration
openAiChatModel;@Resourceprivate
nowDateToolService;@Bean("openAiChatClient")public
openAiChatClient(Wea***rJiaService
ChatClient.builder(openAiChatModel).defaultTools(nowDateToolService).build();}
class="language-java">@GetMapping(value
"text/html;charset=utf-8")public
stream(@RequestParam("question")
openAiChatClient.prompt().user(question).stream().content();}
并在浏览器中问关于时间的问题,会给出系统时间
src="https://i-blog.csdnimg.cn/direct/c0552ef5305b445fb213e0e9269e6984.png"
width="1488">
在前⾯的示例中,我们使⽤了⼀个⼯具来确定当前⽇期和时间。
在这个例⼦中,我们将定义第⼆个⼯
具,⽤于在特定时间设置警报。
⽬标是从现在开始设置10分钟的警报,因此我们需要为模型提供这两
格式的时间。
然后,该⼯具将向控制台打印⼀条消息,指示已在给定时间内设置报警。
与
class="language-java">@Tool(description
setAlarm(@ToolParam(description
time){log.info("时间是:{}",time);LocalDateTime
localDateTime=LocalDateTime.parse(time);log.info("转换后的时间:{}",localDateTime);}
您可以通过使⽤
对⽅法进⾏注释,将其转化为⼯具。
如上述入门案例所示。
@Tool
注释允许您提供有关⼯具的关键信息:
标识⼯具。
因此,不允许在同⼀类中有两个同名⼯具。
对于特定的聊天请求,该名称在模型可
1)">(可以不写)
:⼯具的描述,模型可以使⽤它来了解何时以及如何调⽤⼯具。
如果没有提
供,⽅法名称将⽤作⼯具描述。
然⽽,强烈建议提供详细的描述,因为这对于模型理解⼯具的
⽬的以及如何使⽤它⾄关重要。
如果不能提供⼀个好的描述,可能会导致模型在应该使⽤的时
1)">(要写)
:⼯具结果是应该直接返回给客户端还是传递回模型。
还是可选的。
默认情况下,所有输⼊参数都被认为是必需的。
"text/html;charset=utf-8")public
Flux
stream2(@RequestParam("question")
String
ReflectionUtils.findMethod(NowDateToolService.class,"getNowDate");//开始创建工具ToolDefinition
toolDefinition
ToolDefinitions.builder(method).description("获取⽤户时区中的当前时间").name("getCurrentDateTime2").build();//开始注册工具MethodToolCallback
methodToolCallback
MethodToolCallback.builder().toolDefinition(toolDefinition).toolMethod(method).toolObject(nowDateToolService)
必须是DateTimeToolsService类的实例.build();return
openAiChatClient.prompt().toolCallbacks(methodToolCallback).user(question).stream().content();}
删掉serviceImp中的@Tool注解即可实现。
SpringAI
。
案例--查看城市天气(假的)
定义两个实体类
com.jiazhong.mingxing.ai.siliconflow.mcp.glm.bean;
public
com.jiazhong.mingxing.ai.siliconflow.mcp.glm.service;
import
com.jiazhong.mingxing.ai.siliconflow.mcp.glm.bean.Wea***r;
import
org.springframework.stereotype.Service;
import
Function
}
com.jiazhong.mingxing.ai.siliconflow.mcp.glm.service.impl;
com.jiazhong.mingxing.ai.siliconflow.mcp.glm.bean.Wea***r;
com.jiazhong.mingxing.ai.siliconflow.mcp.glm.service.Wea***rJiaService;
org.springframework.stereotype.Service;
{@Override//因为Wea***rRequest是内部类,在Wea***r类中,所以要使用Wea***r.Wea***rRequestpublic
("西安".equals(wea***rRequest.city())){return
Wea***r.Wea***rResponse(30.1);}else
("宝鸡".equals(wea***rRequest.city())){return
Wea***r.Wea***rResponse(25.4);}else
("漠河".equals(wea***rRequest.city())){return
Wea***r.Wea***rResponse(-27.9);}return
class="language-java">@GetMapping(value
"stream3",produces
"text/html;charset=utf-8")public
Flux
stream3(@RequestParam("question")
String
question){FunctionToolCallback
toolCallback=FunctionToolCallback.builder("wea***rJiaServiceImpl",wea***rJiaService).description("获取到指定位置的天气").inputType(Wea***r.Wea***rRequest.class).build();return
openAiChatClient.prompt().toolCallbacks(toolCallback).user(question).stream().content();}
class="language-java">@Bean("openAiChatClient")public
ChatClient
openAiChatClient(Wea***rJiaService
wea***rJiaService,
amapSrvice){FunctionToolCallback
toolCallback=FunctionToolCallback.builder("wea***rJiaServiceImpl",wea***rJiaService).description("获取到执行位置的天气").inputType(Wea***r.Wea***rRequest.class).build();return
ChatClient.builder(openAiChatModel).defaultTools(wea***rJiaService)/*.defaultToolNames("currentWea***r","currentDressing")*/.defaultTools(toolCallback).build();}
动态规范
com.jiazhong.mingxing.ai.siliconflow.mcp.glm.config;
import
com.jiazhong.mingxing.ai.siliconflow.mcp.glm.bean.Wea***r;
import
com.jiazhong.mingxing.ai.siliconflow.mcp.glm.service.DressingService;
import
com.jiazhong.mingxing.ai.siliconflow.mcp.glm.service.Wea***rJiaService;
import
org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.context.annotation.Bean;
import
org.springframework.context.annotation.Configuration;
import
wea***rJiaService;@Resourceprivate
DressingService
dressingService;@Bean("currentWea***r")public
Function
wea***r(){return
wea***rJiaService;}@Bean("currentDressing")public
Function
dressing(){return
}
@Bean("openAiChatClient")public
ChatClient
openAiChatClient(Wea***rJiaService
wea***rJiaService,
amapSrvice){/*FunctionToolCallback
toolCallback=FunctionToolCallback.builder("wea***rJiaServiceImpl",wea***rJiaService).description("获取到执行位置的天气").inputType(Wea***r.Wea***rRequest.class).build();*/return
ChatClient.builder(openAiChatModel)/*.defaultTools(currentWea***r)*/.defaultToolNames("currentWea***r")/*
.defaultTools(amapSrvice)*/.build();}
class="post-meta-container">
作为专业的SEO优化服务提供商,我们致力于通过科学、系统的搜索引擎优化策略,帮助企业在百度、Google等搜索引擎中获得更高的排名和流量。我们的服务涵盖网站结构优化、内容优化、技术SEO和链接建设等多个维度。
| 服务项目 | 基础套餐 | 标准套餐 | 高级定制 |
|---|---|---|---|
| 关键词优化数量 | 10-20个核心词 | 30-50个核心词+长尾词 | 80-150个全方位覆盖 |
| 内容优化 | 基础页面优化 | 全站内容优化+每月5篇原创 | 个性化内容策略+每月15篇原创 |
| 技术SEO | 基本技术检查 | 全面技术优化+移动适配 | 深度技术重构+性能优化 |
| 外链建设 | 每月5-10条 | 每月20-30条高质量外链 | 每月50+条多渠道外链 |
| 数据报告 | 月度基础报告 | 双周详细报告+分析 | 每周深度报告+策略调整 |
| 效果保障 | 3-6个月见效 | 2-4个月见效 | 1-3个月快速见效 |
我们的SEO优化服务遵循科学严谨的流程,确保每一步都基于数据分析和行业最佳实践:
全面检测网站技术问题、内容质量、竞争对手情况,制定个性化优化方案。
基于用户搜索意图和商业目标,制定全面的关键词矩阵和布局策略。
解决网站技术问题,优化网站结构,提升页面速度和移动端体验。
创作高质量原创内容,优化现有页面,建立内容更新机制。
获取高质量外部链接,建立品牌在线影响力,提升网站权威度。
持续监控排名、流量和转化数据,根据效果调整优化策略。
基于我们服务的客户数据统计,平均优化效果如下:
我们坚信,真正的SEO优化不仅仅是追求排名,而是通过提供优质内容、优化用户体验、建立网站权威,最终实现可持续的业务增长。我们的目标是与客户建立长期合作关系,共同成长。
Demand feedback