虚构猫MCP文档
概述
虚构猫MCP(模型上下文协议)为AI模型提供了访问和检索虚构猫数据的能力。该MCP允许模型从虚构猫API中获取随机猫或检索指定数量的猫。
安装
要在应用程序中使用此MCP,您需要将其与MCP兼容的客户端集成。MCP在遵循模型上下文协议规范的JSON文件中定义。
特性
此MCP提供两个主要功能:
- get_random_cat:检索单个随机猫
- get_cats:检索指定数量的猫
使用示例
使用get_random_cat
此函数从数据库中检索一只随机猫。它不需要任何参数。
// Example client code
const result = await client.call('get_random_cat');
console.log(result);示例响应:
{
"uuid": "f60dd86b-6061-448a-9a25-16774f5acdea",
"name": "Zoey",
"description": "A sock thief with a hidden collection under the bed. Enjoys playing with toys. Fur is fluffy and siamese.",
"image": "https://i.ibb.co/PZFbJ7J2/5.png",
"date_created": "2024-10-11T23:52:07+00:00"
}使用get_cats
此函数用于从数据库中检索多只猫。它需要一个参数 n 指定要检索多少只猫。
// Example client code
const result = await client.call('get_cats', { n: 3 });
console.log(result);示例响应:
[
{
"uuid": "835a97e8-0238-4705-81a0-ef5cb8edb88f",
"name": "Winston",
"description": "A social butterfly who greets all visitors with a friendly meow. Enjoys watching birds. Fur is smooth and tabby.",
"image": "https://i.ibb.co/4n13WPTM/10.png",
"date_created": "2024-10-19T23:52:07+00:00"
},
{
"uuid": "c4b781d0-1e52-47dd-b72e-bbf9b5220147",
"name": "Whiskers",
"description": "A vertical explorer who scales the tallest furniture. Has gentle gold eyes. Enjoys napping in sunbeams.",
"image": "https://i.ibb.co/Z12FSs1g/1.png",
"date_created": "2024-09-17T23:52:07+00:00"
},
{
"uuid": "fde8f5af-90f8-4f23-8c14-60cc5d7b5a9a",
"name": "Winston",
"description": "A vocal feline who talks all day long about everything and nothing. Enjoys watching birds. Personality is friendly.",
"image": "https://i.ibb.co/Z12FSs1g/1.png",
"date_created": "2024-05-24T23:52:07+00:00"
}
]函数参考
get_random_cat
从虚构猫API中检索一个随机猫。
参数:无
退货:具有以下属性的猫对象:
uuid(string):猫的唯一标识符name(string):猫的名字description(string):猫的特征和性格的文字描述image(string):猫图片的URLdate_created(string):以ISO 8601格式创建猫的时间戳
get_cats
从虚构的猫API检索指定数量的猫。
参数:
n(整数,必填):要检索的猫的数量
退货:一个cat对象数组,每个对象具有以下属性:
uuid(string):猫的唯一标识符name(string):猫的名字description(string):猫的特征和性格的文字描述image(string):猫图片的URLdate_created(string):以ISO 8601格式创建猫的时间戳
错误处理
MCP处理以下错误情况:
- API连接错误:如果虚构猫API不可用,MCP将返回适当的错误消息。
- 无效参数:如果提供的参数无效(例如
n),MCP将返回错误。
实现细节
此MCP按照模型上下文协议规范实现为JSON文件。它定义了服务器信息、工具定义和API端点配置。
MCP连接到虚构的猫API:
- 基本URL:
https://fictionalcats.netlify.app/.netlify/functions/api - 随机猫端点:
/cats/random - 多猫端点:
/cats?n={n}
出版
此MCP可以发布到MCP注册表,如smithery.ai,使其可用于支持模型上下文协议的ai模型和应用程序。
