agentgateway 简单试用
以下是一个简单示例,主要测试多mcp tools 的聚合,集成了基于litserve 的mcp server 以及genai toolbox
安装
目前github 上暂时未系统mac x86 架构的包,可以自己编译
- 命令
git clone https://github.com/agentgateway/agentgateway.git
make build
配置使用
- genai toolbox
集成了pg 测试, 具体pg 表以及数据可以参考官方示例文档
sources:my-pg-source:kind: postgreshost: 127.0.0.1port: 5432database: toolbox_dbuser: postgrespassword: dalongdemo
tools:search-hotels-by-name:kind: postgres-sqlsource: my-pg-sourcedescription: 通过名称搜索酒店信息parameters:- name: nametype: stringdescription: 酒店名称。statement: SELECT * FROM hotels WHERE name ILIKE '%' || $1 || '%';search-hotels-by-location:kind: postgres-sqlsource: my-pg-sourcedescription: 通过位置搜索酒店信息parameters:- name: locationtype: stringdescription: 酒店位置。statement: SELECT * FROM hotels WHERE location ILIKE '%' || $1 || '%';book-hotel:kind: postgres-sqlsource: my-pg-sourcedescription: >-Book a hotel by its ID. If the hotel is successfully booked, returns a NULL, raises an error if not.parameters:- name: hotel_idtype: stringdescription: The ID of the hotel to book.statement: UPDATE hotels SET booked = B'1' WHERE id = $1;update-hotel:kind: postgres-sqlsource: my-pg-sourcedescription: >-Update a hotel's check-in and check-out dates by its ID. Returns a messageindicating whether the hotel was successfully updated or not.parameters:- name: hotel_idtype: stringdescription: The ID of the hotel to update.- name: checkin_datetype: stringdescription: The new check-in date of the hotel.- name: checkout_datetype: stringdescription: The new check-out date of the hotel.statement: >-UPDATE hotels SET checkin_date = CAST($2 as date), checkout_date = CAST($3as date) WHERE id = $1;cancel-hotel:kind: postgres-sqlsource: my-pg-sourcedescription: Cancel a hotel by its ID.parameters:- name: hotel_idtype: stringdescription: The ID of the hotel to cancel.statement: UPDATE hotels SET booked = B'0' WHERE id = $1;
toolsets:my-toolset:- search-hotels-by-name- search-hotels-by-location- book-hotel- update-hotel- cancel-hotel
启动
./toolbox --tools-file tools.yaml
- litserve mcp server
import litserve as ls
from litserve.mcp import MCP
from pydantic import BaseModel
from litserve.specs.openai import ChatMessage
from litserve.specs import OpenAIEmbeddingSpec,OpenAISpecclass AddInput(BaseModel):a: intb: intclass SubtractInput(BaseModel):a: intb: intclass SendEmailInput(BaseModel):username: strcontent: strclass AddApi(ls.LitAPI):def setup(self, device):self.model1 = lambda x, y: x + ydef decode_request(self, request: AddInput, **kwargs):return (request.a, request.b)def predict(self, x):a, b = xresult = self.model1(a, b)print(f"Calculating sum of {a} and {b}: {result}")return {"output": result}class SubtractApi(ls.LitAPI):def setup(self, device):self.model1 = lambda x, y: x - ydef decode_request(self, request: SubtractInput, **kwargs):return (request.a, request.b)def predict(self, x):a, b = xresult = self.model1(a, b)print(f"Calculating difference of {a} and {b}: {result}")return {"output": result}
class SendEmailApi(ls.LitAPI):def setup(self, device):passdef decode_request(self, request: SendEmailInput, **kwargs):return (request.username, request.content)def predict(self, x):username, content = xprint(f"Sending email to {username} with content: {content}")return {"output": f"Email sent to {username} with content: {content}"}
if __name__ == "__main__":mcpadd = MCP(description="计算加法",name="get_sum")mcpsubtract = MCP(description="计算减法",name="get_difference")mcpsendemail = MCP(description="发送邮件",name="send_email")api = AddApi(mcp=mcpadd,max_batch_size=1,api_path="/add")api_subtract = SubtractApi(mcp=mcpsubtract,max_batch_size=1,api_path="/subtract")api_send_email = SendEmailApi(mcp=mcpsendemail,max_batch_size=1,api_path="/send_email")server = ls.LitServer([api, api_subtract,api_send_email], accelerator="auto")server.run(port=8000)
- agentgateway 集成配置
config.yaml
binds:
- port: 3000listeners:- routes:- backends:- mcp:name: defaulttargets:- name: demomcp:host: localhostport: 8000path: /mcp/- name: everythingmcp:host: 127.0.0.1port: 5000path: /mcp/my-toolset/
- 启动
./agentgateway -f config.yaml
- 效果
说明
agentgateway 最近一个版本的调整了不少配置,如果要使用最好解决源码学习,同时目前看ui 部分是有一些问题的,整体来说还是很不错的,目前来说bug还是不少的,实际上genai toolbox 的toolsets 也是一个挺有意思的设计
参考资料
crates/agentgateway/src/types/agent.rs
https://github.com/agentgateway/agentgateway
https://agentgateway.dev/
https://github.com/agentgateway/agentgateway/releases/tag/v0.5.2
https://github.com/cloudflare/pingora
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/907608.shtml
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!相关文章
SVG动画优化全攻略:从设计到性能提升
本文详细介绍了如何通过清洁设计、路径简化、代码分层和元素复用等技术优化SVG动画,涵盖工具选择、结构设计到CSS动画实现的全流程,帮助开发者创建高性能的SVG动画效果。粉碎动画第四部分:优化SVG
SVG动画让我回想起…
深入解析:Go 1.25.1 自定义包调用
pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco", "Courier New", …
MX 练石 2026 NOIP #7
0 + 10 + 10 + 0 = 20, Rank 152/199.好难好难好难好难,为数不多的罚坐了。
4h20min 怒砍 20pts /ohMX 练石 2025 NOIP #6
链接:link
题解:link
时间:4h20min (2025.09.18 13:50~18:10)
题目数:4
难度:A
B
C
D估…
国内AI云市场:挤不进前三,生存将成问题!
微信视频号:sph0RgSyDYV47z6快手号:4874645212抖音号:dy0so323fq2w小红书号:95619019828B站1:UID:3546863642871878B站2:UID: 3546955410049087中国AI云市场已形成“一大四强”的格局,阿里云以35.8%的份额独占鳌…
P14053 [SDCPC 2019] Median 题解
P14053 [SDCPC 2019] Median 题解P14053 [SDCPC 2019] Median 题解
一道水题。
观察题意,很快我们可以发现,对于元素 \(i\),其合不合法取决于一定大于 \(i\) 的数的个数与一定小于 \(i\) 的数的个数。
这时,我们只…
lQueryDef查询Evaluate报该几何不包含M值问题。
地理数据库既包括空间,又包括属性,属性类似于SQL表,理论上支持标准SQL查询。lQueryDef接口提供了高效查询方法,适用于对属性表或要素类的属性进行筛选和检索。
问题描述
一个简单的面积求和示例如下:IQueryDefFac…
我的首个RCE漏洞发现之旅:Apache ActiveMQ远程代码执行实战
本文详细讲述了作者如何通过系统化的子域名枚举和端口扫描,发现Apache ActiveMQ的CVE-2023-46604远程代码执行漏洞的全过程,包含具体的工具使用方法和实战技巧。我的首个RCE漏洞发现经历
大家好!在这篇文章中,我将…
北京市社保费用差额补缴计算工具
北京市社保费用差额补缴计算工具9月18日北京市发布了社会保险缴费工资基数上下限调整的通告,自2025年7月起,社保基数下限由原来的 6821元提高到7162元。
这样一来,之前已经缴了7月份社保且社保基数不到7162元的就需…
使用自签名SSL证书有什么风险?
自签名SSL证书,指的是由用户自行生成密钥对并予以签名的证书,无需经由第三方权威证书颁发机构(CA)审核。鉴于其具备零成本、生成便捷的特性,该证书常被应用于个人测试、内部临时服务等非生产场景。
然而,相较于权…
CDN可以使用iTrustSSL通配符证书吗?
CDN,即内容分发网络,它是一种通过在多个地理位置分散部署服务器节点,将网站的内容缓存并分发到离用户最近的节点上,从而显著提高网站内容的访问速度、降低延迟,并减轻源服务器负载的技术架构。借助CDN,网站能够更…
[ssh]:SecureCRT的配置
[ssh]:SecureCRT的配置[ssh]:SecureCRT的配置一、有用配置1. Terminal -> Emulation 2. Terminal -> Apperance 二、参考1. 无.本文由 lnlidawei 原创、整理、转载,本文来自于【博客园】…
OpenCvSharp基于颜色反差规避FBA面单贴标
01
规避原理
1.抠图,根据色差或者根据固定包裹位置以及包裹尺寸抠出纸箱图片
2.色差,获取纸箱上所有背景色的灰度值
3.采图,采集大量视野相同,光源相同面单的色差灰度值,整理区间
4.取反,所有非面单灰度值区间的…
[LeetCode] 3408. Design Task Manager
There is a task management system that allows users to manage their tasks, each associated with a priority. The system should efficiently handle adding, modifying, executing, and removing tasks.
Implem…
Torrent File Editor 1.0.0
https://torrent-file-editor.github.io/
下载:https://github.com/torrent-file-editor/torrent-file-editor/releases
US$428 XTOOL X-100 PAD Tablet Key Programmer with EEPROM Adapter Support Special Functions
XTOOL X100 PAD Tablet Key Programmer with EEPROM Adapter Support Special FunctionsNotice: 1. Language: English, Spanish, French, German, Norwegian, Russian, Persian, Arabic, Polish, Hindi and Portugues…
US$49 Multi-languages Smart Zed-Bull With Mini Type No Tokens Needed
Multi-languages Smart Zed-Bull With Mini Type No Tokens NeededTop 6 Reasons to Get the Smart Zed-Bull:1.Language:English, Turkish, Italian, Spanish and Portugues2. No Tokens Needed!3. New: Support 8C a…
US$149 Foxwell NT630 Elite ABS and Airbag Reset Tool with SAS
Foxwell NT630 Elite ABS and Airbag Reset Tool with SASUpdate Online Free Lifetime.Support Multi-Language: English, French, Spanish, Hungrian, Korean, Japanese & GermanFoxwell NT630 Elite Features a…
AI CodeReview + Devops协同
在软件开发团队里,Code Review 是非常重要的一个质量保障环境。好的 Code Review 能促进团队成长,差的 Code Review 形同流水。而在有了 LLM 之后,事情又发生了一些微妙的变化:随着代码产量上升,需要 review 的代…