Skip to main content
Glama
angheljf

NYTimes Article Search MCP Server

search_articles

Search for New York Times articles published within the last 30 days using a specific keyword to find relevant content quickly.

Instructions

Search NYTimes articles from the last 30 days based on a keyword

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keywordYesKeyword to search for in articles

Implementation Reference

  • Executes the search_articles tool: validates input, queries NYTimes API for recent articles matching the keyword, maps response to simplified format, returns as JSON text content.
    async (request) => {
      if (request.params.name !== "search_articles") {
        throw new McpError(
          ErrorCode.MethodNotFound,
          `Unknown tool: ${request.params.name}`
        );
      }
    
      if (!isValidSearchArticlesArgs(request.params.arguments)) {
        throw new McpError(
          ErrorCode.InvalidParams,
          "Invalid search arguments"
        );
      }
    
      const keyword = request.params.arguments.keyword;
    
      try {
        const response = await this.axiosInstance.get<NYTimesApiResponse>(API_CONFIG.ENDPOINT, {
          params: {
            q: keyword,
            sort: 'newest',
            'begin_date': this.getDateString(30),  // 30 days ago
            'end_date': this.getDateString(0)  // today
          }
        });
    
        const articles: ArticleSearchResult[] = response.data.response.docs.map(article => ({
          title: article.headline.main,
          abstract: article.abstract,
          url: article.web_url,
          publishedDate: article.pub_date,
          author: article.byline.original || 'Unknown'
        }));
    
        return {
          content: [{
            type: "text",
            text: JSON.stringify(articles, null, 2)
          }]
        };
      } catch (error) {
        if (axios.isAxiosError(error)) {
          return {
            content: [{
              type: "text",
              text: `NYTimes API error: ${error.response?.data.message ?? error.message}`
            }],
            isError: true,
          }
        }
        throw error;
      }
    }
  • src/index.ts:94-112 (registration)
    Registers the 'search_articles' tool in the MCP ListToolsRequestSchema response, including name, description, and input schema.
    this.server.setRequestHandler(
      ListToolsRequestSchema,
      async () => ({
        tools: [{
          name: "search_articles",
          description: "Search NYTimes articles from the last 30 days based on a keyword",
          inputSchema: {
            type: "object",
            properties: {
              keyword: {
                type: "string",
                description: "Keyword to search for in articles"
              }
            },
            required: ["keyword"]
          }
        }]
      })
    );
  • TypeScript interface defining the input arguments for search_articles tool.
    export interface SearchArticlesArgs {
      keyword: string;
    }
  • Type guard function to validate search_articles arguments before execution.
    export function isValidSearchArticlesArgs(args: any): args is SearchArticlesArgs {
      return (
        typeof args === "object" &&
        args !== null &&
        "keyword" in args &&
        typeof args.keyword === "string"
      );
    }
  • Helper function to format date for NYTimes API query (days ago).
    private getDateString(daysAgo: number): string {
      const date = new Date();
      date.setDate(date.getDate() - daysAgo);
      return date.toISOString().split('T')[0].replace(/-/g, '');
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions the 30-day time constraint, which is useful, but fails to describe critical behaviors such as response format, pagination, error handling, or any rate limits. For a search tool with zero annotation coverage, this leaves significant gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core functionality without unnecessary words. Every part ('Search NYTimes articles from the last 30 days based on a keyword') contributes directly to understanding the tool's purpose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations and output schema, the description is incomplete. It covers the basic purpose and time constraint but omits details on behavioral traits, response structure, and usage guidelines. For a search tool, this leaves the agent with insufficient context to use it effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with the parameter 'keyword' well-documented in the schema. The description adds minimal value by implying keyword-based filtering but doesn't provide additional semantics like search syntax or examples. Baseline 3 is appropriate when the schema handles parameter documentation effectively.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Search NYTimes articles') and resource ('articles'), specifying the scope ('from the last 30 days') and filtering criteria ('based on a keyword'). It lacks sibling tool differentiation, but since there are no sibling tools, this doesn't reduce clarity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides basic context (searching recent articles by keyword) but offers no explicit guidance on when to use this tool versus alternatives, prerequisites, or exclusions. Without siblings, the need for differentiation is lower, but it still lacks usage context like rate limits or authentication needs.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/angheljf/nyt'

If you have feedback or need assistance with the MCP directory API, please join our Discord server