import { McpServer } from "skybridge/server";
import { z } from "zod";
const server = new McpServer(
{ name: "hotel-booking", version: "1.0.0" },
{}
)
.registerWidget("search-hotels", {
description: "Search for hotels",
}, {
inputSchema: {
city: z.string().describe("City to search"),
checkIn: z.string().describe("Check-in date"),
checkOut: z.string().describe("Check-out date"),
guests: z.number().optional().default(2),
},
outputSchema: {
hotels: z.array(z.object({
id: z.string(),
name: z.string(),
price: z.number(),
rating: z.number(),
})),
},
}, async ({ city, checkIn, checkOut, guests }) => {
const hotels = await searchHotels({ city, checkIn, checkOut, guests });
return {
content: [{ type: "text", text: `Found ${hotels.length} hotels in ${city}` }],
structuredContent: { hotels },
};
})
.registerWidget("hotel-details", {
description: "Get hotel details",
}, {
inputSchema: {
hotelId: z.string(),
},
}, async ({ hotelId }) => {
const hotel = await getHotel(hotelId);
return {
content: [{ type: "text", text: `Showing details for ${hotel.name}` }],
structuredContent: hotel,
};
});
export type AppType = typeof server;
export default server;