browse
Open the default browser to view detailed information about a Douban book using its unique identifier.
Instructions
open default browser and browse douban book detail
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | douban book id, e.g. "1234567890" |
Implementation Reference
- src/index.ts:189-202 (handler)Handler function for the 'browse' tool. It validates the required 'id' parameter, opens the corresponding Douban book detail page in the default browser using the 'open' package, and returns a confirmation text message.async (args) => { if (!args.id) { throw new McpError(ErrorCode.InvalidParams, "douban book id must be provided") } await open(`https://book.douban.com/subject/${args.id}/`); return { content: [{ type: "text", text: `The Douban Book Page has been opened in your default browser`, }] } }
- src/index.ts:186-188 (schema)Input schema for the 'browse' tool using Zod: defines a required 'id' string parameter for the Douban book ID.{ id: z.string().describe('douban book id, e.g. "1234567890"') },
- src/index.ts:183-203 (registration)Registration of the 'browse' tool on the MCP server, including tool name (TOOL.BROWSE), description, input schema, and inline handler function.server.tool( TOOL.BROWSE, "open default browser and browse douban book detail", { id: z.string().describe('douban book id, e.g. "1234567890"') }, async (args) => { if (!args.id) { throw new McpError(ErrorCode.InvalidParams, "douban book id must be provided") } await open(`https://book.douban.com/subject/${args.id}/`); return { content: [{ type: "text", text: `The Douban Book Page has been opened in your default browser`, }] } } );
- src/types.ts:6-6 (helper)Definition of the TOOL.BROWSE constant in the TOOL enum, providing the string identifier 'browse' used in tool registration.BROWSE = 'browse',