get_blog_post_content
Extract article content, title, author, publish date, and tags from blog.duyet.net or duyet.net posts using a URL.
Instructions
Get the full content of a specific blog post by URL. Extracts article text, title, and metadata (author, publish date, tags) from blog.duyet.net or duyet.net posts.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | The URL of the blog post to retrieve content from (blog.duyet.net or duyet.net) |
Implementation Reference
- src/tools/blog-posts.ts:24-65 (handler)The handler function implementing the tool logic. It fetches the blog post content via `fetchBlogPostContent`, formats it as JSON in a text content block, and handles errors similarly.async ({ url }) => { try { const result = await fetchBlogPostContent(url); return { content: [ { type: "text", text: JSON.stringify( { url: result.url, title: result.title, content: result.content, metadata: result.metadata, contentLength: result.contentLength, }, null, 2, ), }, ], }; } catch (error) { return { content: [ { type: "text", text: JSON.stringify( { error: "Failed to retrieve blog post content", message: error instanceof Error ? error.message : "Unknown error", }, null, 2, ), }, ], isError: true, }; } },
- src/tools/blog-posts.ts:18-22 (schema)The input schema for the tool, validating the 'url' parameter as a valid URL using Zod.inputSchema: { url: urlSchema.describe( "The URL of the blog post to retrieve content from (blog.duyet.net or duyet.net)", ), },
- src/tools/blog-posts.ts:11-67 (registration)The registration function that registers the 'get_blog_post_content' tool with the MCP server, including schema and handler.export function registerGetBlogPostContentTool(server: McpServer) { server.registerTool( "get_blog_post_content", { title: "Get Blog Post Content", description: "Get the full content of a specific blog post by URL. Extracts article text, title, and metadata (author, publish date, tags) from blog.duyet.net or duyet.net posts.", inputSchema: { url: urlSchema.describe( "The URL of the blog post to retrieve content from (blog.duyet.net or duyet.net)", ), }, }, async ({ url }) => { try { const result = await fetchBlogPostContent(url); return { content: [ { type: "text", text: JSON.stringify( { url: result.url, title: result.title, content: result.content, metadata: result.metadata, contentLength: result.contentLength, }, null, 2, ), }, ], }; } catch (error) { return { content: [ { type: "text", text: JSON.stringify( { error: "Failed to retrieve blog post content", message: error instanceof Error ? error.message : "Unknown error", }, null, 2, ), }, ], isError: true, }; } }, ); }
- src/tools/index.ts:29-30 (registration)Top-level call to register the tool during all tools registration.registerGetBlogPostContentTool(server); logger.tool("get_blog_post_content", "registered");
- src/core/blog.ts:312-327 (helper)Helper function called by the handler to fetch and cache the blog post content from the given URL.export async function fetchBlogPostContent(url: string): Promise<{ url: string; title: string | null; content: string; metadata: { author?: string; publishDate?: string; tags?: string[]; }; contentLength: number; }> { // Use URL as cache key (normalized) const cacheKey = `blog-post-${encodeURIComponent(url)}`; return cacheOrFetch(cacheKey, CACHE_CONFIGS.BLOG, () => fetchBlogPostContentInternal(url)); }