Zum Inhalt springen

WebMCP Blog Posts Filter Tool

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

Draft - awaiting review

The site has a blog section (docs/blog/) with posts in German and English. Filtering by date range is a natural agent use case: “show me posts since X date” or “what was posted this week?”

  • Blog posts are chronologically ordered but not queryable by date range
  • Agent would need to scan all posts and filter client-side

WebMCP tool get_posts_since() returns posts published after a given date.

As an agent, I want to fetch blog posts published since a specific date.

Acceptance Criteria:

  • Agent calls get_posts_since(date) with ISO date string
  • Tool returns posts with publish date >= requested date
  • Each result: title, slug, date, language hint
ID Requirement
FR-001 Tool name: get_posts_since
FR-002 Input: date parameter (ISO 8601 date string, e.g., “2026-07-01”)
FR-003 Output: JSON array { title, slug, date, lang }
FR-004 readOnlyHint: true
FR-005 Date comparison is inclusive (posts ON that date included)
const BLOG_POSTS = [/* build-time Astro collection */];
document.modelContext.registerTool({
name: "get_posts_since",
description: "Get blog posts published on or after a specific date. Returns title, slug, date, and language.",
inputSchema: {
type: "object",
properties: {
date: {
type: "string",
format: "date",
description: "ISO 8601 date (e.g., 2026-07-01)"
}
},
required: ["date"]
},
execute: async ({ date }) => {
const since = new Date(date);
const matches = BLOG_POSTS
.filter(p => new Date(p.date) >= since)
.map(p => ({ title: p.title, slug: p.slug, date: p.date, lang: p.lang || "en" }));
return matches.sort((a, b) => new Date(b.date) - new Date(a.date));
},
annotations: { readOnlyHint: true }
});
Test Input Expected
Future date “2027-01-01” Returns []
Past date “2025-01-01” Returns all posts
Specific date “2026-07-06” Returns posts from that date onward