Skip to main content
Glama
PlayAINetwork

ChainGPT AI News MCP Server

getAINews

Search AI-related crypto and Web3 news by filtering with categories, blockchains, tokens, keywords, and date range.

Instructions

Fetch the latest AI-related crypto and Web3 news with optional filtering by categories, blockchains, tokens, keywords, and date range

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
categoriesNoCategories to filter by (e.g., ['defi', 'nft', 'gaming', 'dao', 'metaverse'])
blockchainsNoBlockchains/networks to filter by (e.g., ['ethereum', 'bitcoin', 'solana', 'polygon'])
tokensNoTokens/cryptocurrencies to filter by (e.g., ['bitcoin', 'ethereum', 'usdt', 'bnb'])
searchQueryNoKeyword or phrase to search for in news titles and descriptions
fetchAfterNoOnly return news published after this date (ISO 8601 format, e.g., '2024-01-01T00:00:00Z')
limitNoNumber of news articles to return (default: 10)
offsetNoNumber of items to skip for pagination (default: 0)

Implementation Reference

  • index.js:197-316 (registration)
    The tool is registered with the MCP server using server.tool(), defining its name, description, schema, and handler.
    server.tool(
      "getAINews",
      "Fetch the latest AI-related crypto and Web3 news with optional filtering by categories, blockchains, tokens, keywords, and date range",
      {
        categories: z.array(z.string()).optional().describe("Categories to filter by (e.g., ['defi', 'nft', 'gaming', 'dao', 'metaverse'])"),
        blockchains: z.array(z.string()).optional().describe("Blockchains/networks to filter by (e.g., ['ethereum', 'bitcoin', 'solana', 'polygon'])"),
        tokens: z.array(z.string()).optional().describe("Tokens/cryptocurrencies to filter by (e.g., ['bitcoin', 'ethereum', 'usdt', 'bnb'])"),
        searchQuery: z.string().optional().describe("Keyword or phrase to search for in news titles and descriptions"),
        fetchAfter: z.string().optional().describe("Only return news published after this date (ISO 8601 format, e.g., '2024-01-01T00:00:00Z')"),
        limit: z.number().default(10).describe("Number of news articles to return (default: 10)"),
        offset: z.number().default(0).describe("Number of items to skip for pagination (default: 0)")
      },
      async ({ categories, blockchains, tokens, searchQuery, fetchAfter, limit = 10, offset = 0 }) => {
        try {
          const apiKey = process.env.CHAINGPT_API_KEY;
          if (!apiKey) {
            return {
              content: [{
                type: "text",
                text: JSON.stringify({
                  status: "error",
                  message: "ChainGPT API key not found. Please set the CHAINGPT_API_KEY environment variable.",
                  suggestion: "Add CHAINGPT_API_KEY=your_api_key to your environment variables"
                }, null, 2)
              }]
            };
          }
    
          const client = initializeClient(apiKey);
    
          const categoryIds = parseTermsToIds(categories, CATEGORY_MAPPINGS);
          const subCategoryIds = parseTermsToIds(blockchains, SUBCATEGORY_MAPPINGS);
          const tokenIds = parseTermsToIds(tokens, TOKEN_MAPPINGS);
    
          const requestParams = {
            limit,
            offset,
            sortBy: 'createdAt'
          };
    
          if (categoryIds.length > 0) {
            requestParams.categoryId = categoryIds;
          }
    
          if (subCategoryIds.length > 0) {
            requestParams.subCategoryId = subCategoryIds;
          }
    
          if (tokenIds.length > 0) {
            requestParams.tokenId = tokenIds;
          }
    
          if (searchQuery) {
            requestParams.searchQuery = searchQuery;
          }
    
          if (fetchAfter) {
            try {
              requestParams.fetchAfter = new Date(fetchAfter);
            } catch (error) {
              return {
                content: [{
                  type: "text",
                  text: JSON.stringify({
                    status: "error",
                    message: "Invalid date format for fetchAfter. Please use ISO 8601 format (e.g., '2024-01-01T00:00:00Z')",
                    providedDate: fetchAfter
                  }, null, 2)
                }]
              };
            }
          }
    
          const response = await client.getNews(requestParams);
    
          const result = {
            status: "success",
            metadata: {
              totalResults: response.data.length,
              limit,
              offset,
              appliedFilters: {
                categories: categories || [],
                blockchains: blockchains || [],
                tokens: tokens || [],
                searchQuery: searchQuery || null,
                fetchAfter: fetchAfter || null,
                mappedIds: {
                  categoryIds,
                  subCategoryIds,
                  tokenIds
                }
              },
              timestamp: new Date().toISOString()
            },
            data: response.data
          };
    
          return {
            content: [{
              type: "text",
              text: JSON.stringify(result, null, 2)
            }]
          };
    
        } catch (error) {
          return {
            content: [{
              type: "text",
              text: JSON.stringify({
                status: "error",
                message: `Failed to fetch AI news: ${error.message}`,
                errorType: error.constructor.name,
                timestamp: new Date().toISOString()
              }, null, 2)
            }]
          };
        }
      }
    );
  • Zod schema defining the input parameters for the getAINews tool.
    {
      categories: z.array(z.string()).optional().describe("Categories to filter by (e.g., ['defi', 'nft', 'gaming', 'dao', 'metaverse'])"),
      blockchains: z.array(z.string()).optional().describe("Blockchains/networks to filter by (e.g., ['ethereum', 'bitcoin', 'solana', 'polygon'])"),
      tokens: z.array(z.string()).optional().describe("Tokens/cryptocurrencies to filter by (e.g., ['bitcoin', 'ethereum', 'usdt', 'bnb'])"),
      searchQuery: z.string().optional().describe("Keyword or phrase to search for in news titles and descriptions"),
      fetchAfter: z.string().optional().describe("Only return news published after this date (ISO 8601 format, e.g., '2024-01-01T00:00:00Z')"),
      limit: z.number().default(10).describe("Number of news articles to return (default: 10)"),
      offset: z.number().default(0).describe("Number of items to skip for pagination (default: 0)")
    },
  • The handler function that executes the tool logic: validates API key, maps terms to IDs, calls the ChainGPT AI News API, and returns formatted results.
    async ({ categories, blockchains, tokens, searchQuery, fetchAfter, limit = 10, offset = 0 }) => {
      try {
        const apiKey = process.env.CHAINGPT_API_KEY;
        if (!apiKey) {
          return {
            content: [{
              type: "text",
              text: JSON.stringify({
                status: "error",
                message: "ChainGPT API key not found. Please set the CHAINGPT_API_KEY environment variable.",
                suggestion: "Add CHAINGPT_API_KEY=your_api_key to your environment variables"
              }, null, 2)
            }]
          };
        }
    
        const client = initializeClient(apiKey);
    
        const categoryIds = parseTermsToIds(categories, CATEGORY_MAPPINGS);
        const subCategoryIds = parseTermsToIds(blockchains, SUBCATEGORY_MAPPINGS);
        const tokenIds = parseTermsToIds(tokens, TOKEN_MAPPINGS);
    
        const requestParams = {
          limit,
          offset,
          sortBy: 'createdAt'
        };
    
        if (categoryIds.length > 0) {
          requestParams.categoryId = categoryIds;
        }
    
        if (subCategoryIds.length > 0) {
          requestParams.subCategoryId = subCategoryIds;
        }
    
        if (tokenIds.length > 0) {
          requestParams.tokenId = tokenIds;
        }
    
        if (searchQuery) {
          requestParams.searchQuery = searchQuery;
        }
    
        if (fetchAfter) {
          try {
            requestParams.fetchAfter = new Date(fetchAfter);
          } catch (error) {
            return {
              content: [{
                type: "text",
                text: JSON.stringify({
                  status: "error",
                  message: "Invalid date format for fetchAfter. Please use ISO 8601 format (e.g., '2024-01-01T00:00:00Z')",
                  providedDate: fetchAfter
                }, null, 2)
              }]
            };
          }
        }
    
        const response = await client.getNews(requestParams);
    
        const result = {
          status: "success",
          metadata: {
            totalResults: response.data.length,
            limit,
            offset,
            appliedFilters: {
              categories: categories || [],
              blockchains: blockchains || [],
              tokens: tokens || [],
              searchQuery: searchQuery || null,
              fetchAfter: fetchAfter || null,
              mappedIds: {
                categoryIds,
                subCategoryIds,
                tokenIds
              }
            },
            timestamp: new Date().toISOString()
          },
          data: response.data
        };
    
        return {
          content: [{
            type: "text",
            text: JSON.stringify(result, null, 2)
          }]
        };
    
      } catch (error) {
        return {
          content: [{
            type: "text",
            text: JSON.stringify({
              status: "error",
              message: `Failed to fetch AI news: ${error.message}`,
              errorType: error.constructor.name,
              timestamp: new Date().toISOString()
            }, null, 2)
          }]
        };
      }
    }
  • Helper function to convert human-readable category/blockchain/token names to their numeric IDs using the mapping objects.
    function parseTermsToIds(terms, mappingObject) {
      if (!terms || !Array.isArray(terms)) return [];
      
      const ids = [];
      for (const term of terms) {
        const normalizedTerm = term.toLowerCase().trim();
        const id = mappingObject[normalizedTerm];
        if (id !== undefined) {
          ids.push(id);
        }
      }
      return [...new Set(ids)]; 
    }
  • Helper function that lazily initializes the AINews client singleton with the provided API key.
    function initializeClient(apiKey) {
      if (!aiNewsClient) {
        aiNewsClient = new AINews({ apiKey });
      }
      return aiNewsClient;
    }
Behavior3/5

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

No annotations are present, so the description carries full burden. It accurately implies a read-only operation but does not disclose any behavioral details beyond basic fetching, such as data source, rate limits, or error handling.

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?

Single sentence that front-loads the action and efficiently enumerates filters. No wasted words; structure is clear and scannable.

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

Completeness4/5

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

Given 7 optional parameters and no output schema, the description covers the main functionality and filter options. It omits output format but this is acceptable without an output schema. Could mention return type briefly.

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?

Input schema coverage is 100%, so the schema already documents parameters. The description merely summarizes filter options without adding new meaning or constraints beyond what the schema provides.

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

Purpose5/5

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

The description clearly states 'Fetch the latest AI-related crypto and Web3 news with optional filtering...' using a specific verb and resource. It distinguishes the tool's scope even without siblings.

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

Usage Guidelines3/5

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

The description lists what the tool does but provides no guidance on when to use it versus alternatives or any prerequisites. Without siblings, this is less critical, but still lacking explicit context.

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

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/PlayAINetwork/Chaingpt-mcp'

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