Skip to main content
Glama
Dianel555

Paper Search MCP

by Dianel555

search_semantic_scholar

Search academic papers on Semantic Scholar with citation data, year filters, and field-of-study options to find relevant research publications.

Instructions

Search Semantic Scholar for academic papers with citation data

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query string
maxResultsNoMaximum number of results to return
yearNoYear filter (e.g., "2023", "2020-2023")
fieldsOfStudyNoFields of study filter (e.g., ["Computer Science", "Biology"])

Implementation Reference

  • Core implementation of the search functionality using Semantic Scholar Graph API v1, including query parameterization, API rate limiting, error handling, and result parsing into Paper objects.
    async search(query: string, options: SemanticSearchOptions = {}): Promise<Paper[]> {
      await this.rateLimiter.waitForPermission();
    
      try {
        const params: Record<string, any> = {
          query: query,
          limit: Math.min(options.maxResults || 10, 100), // API限制最大100
          fields: [
            'paperId', 'title', 'abstract', 'venue', 'year', 
            'referenceCount', 'citationCount', 'influentialCitationCount',
            'isOpenAccess', 'openAccessPdf', 'fieldsOfStudy', 's2FieldsOfStudy',
            'publicationTypes', 'publicationDate', 'journal', 'authors', 
            'externalIds', 'url'
          ].join(',')
        };
    
        // 添加年份过滤
        if (options.year) {
          params.year = options.year;
        }
    
        // 添加研究领域过滤
        if (options.fieldsOfStudy && options.fieldsOfStudy.length > 0) {
          params.fieldsOfStudy = options.fieldsOfStudy.join(',');
        }
    
        const url = `${this.baseApiUrl}/paper/search`;
        const headers: Record<string, string> = {
          'User-Agent': USER_AGENT,
          'Accept': 'application/json',
          'Accept-Language': 'en-US,en;q=0.9'
        };
    
        // 添加API密钥(如果有)- 根据官方文档推荐的方式
        if (this.apiKey) {
          headers['x-api-key'] = this.apiKey;
        }
    
        logDebug(`Semantic Scholar API Request: GET ${url}`);
        logDebug('Semantic Scholar Request params:', params);
    
        const response = await axios.get(url, { 
          params, 
          headers,
          timeout: TIMEOUTS.DEFAULT,
          // 改善请求可靠性
          maxRedirects: 5,
          validateStatus: (status) => status < 500 // allow 4xx through so we can provide consistent messaging
        });
        
        logDebug(`Semantic Scholar API Response: ${response.status} ${response.statusText}`);
        
        // 处理可能的错误响应
        if (response.status >= 400) {
          // Convert non-throwing 4xx response to unified error handling
          this.handleHttpError({ response, config: response.config }, 'search');
        }
        
        const papers = this.parseSearchResponse(response.data);
        logDebug(`Semantic Scholar Parsed ${papers.length} papers`);
        
        return papers;
      } catch (error: any) {
        logDebug('Semantic Scholar Search Error:', error.message);
        
        // 处理速率限制错误
        if (error.response?.status === 429) {
          const retryAfter = error.response.headers['retry-after'];
          logDebug(
            `Rate limited by Semantic Scholar API. ${retryAfter ? `Retry after ${retryAfter} seconds.` : 'Please wait before making more requests.'}`
          );
        }
        
        // 处理API限制错误
        if (error.response?.status === 403) {
          logDebug('Access denied. Please check your API key or ensure you are within the free tier limits.');
        }
        
        this.handleHttpError(error, 'search');
      }
    }
  • MCP tool call handler case that delegates to the SemanticScholarSearcher instance and formats the response with rate limit information.
    case 'search_semantic_scholar': {
      const { query, maxResults, year, fieldsOfStudy } = args;
      const results = await searchers.semantic.search(query, {
        maxResults,
        year,
        fieldsOfStudy
      });
    
      const rateStatus = searchers.semantic.getRateLimiterStatus();
      const apiKeyStatus = searchers.semantic.hasApiKey()
        ? 'configured'
        : 'not configured (using free tier)';
      const rateLimit = searchers.semantic.hasApiKey() ? '200 requests/minute' : '20 requests/minute';
    
      return jsonTextResponse(
        `Found ${results.length} Semantic Scholar papers.\n\nAPI Status: ${apiKeyStatus} (${rateLimit})\nRate Limiter: ${rateStatus.availableTokens}/${rateStatus.maxTokens} tokens available\n\n${JSON.stringify(
          results.map((paper: Paper) => PaperFactory.toDict(paper)),
          null,
          2
        )}`
      );
    }
  • Zod schema for validating input arguments to the search_semantic_scholar tool.
    export const SearchSemanticScholarSchema = z
      .object({
        query: z.string().min(1),
        maxResults: z.number().int().min(1).max(100).optional().default(10),
        year: z.string().optional(),
        fieldsOfStudy: z.array(z.string()).optional()
      })
      .strip();
  • Tool registration definition including name, description, and JSON input schema, added to the TOOLS array for MCP.
    {
      name: 'search_semantic_scholar',
      description: 'Search Semantic Scholar for academic papers with citation data',
      inputSchema: {
        type: 'object',
        properties: {
          query: { type: 'string', description: 'Search query string' },
          maxResults: {
            type: 'number',
            minimum: 1,
            maximum: 100,
            description: 'Maximum number of results to return'
          },
          year: { type: 'string', description: 'Year filter (e.g., "2023", "2020-2023")' },
          fieldsOfStudy: {
            type: 'array',
            items: { type: 'string' },
            description: 'Fields of study filter (e.g., ["Computer Science", "Biology"])'
          }
        },
        required: ['query']
      }
    },
  • Instantiation of the SemanticScholarSearcher instance, configured with optional API key from environment, and added to the searchers object.
    const semanticSearcher = new SemanticScholarSearcher(process.env.SEMANTIC_SCHOLAR_API_KEY);
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. While 'Search' implies a read-only operation, the description doesn't mention important behavioral aspects like rate limits, authentication requirements, response format, pagination behavior, or error conditions. The mention of 'citation data' hints at what's returned but doesn't provide operational details.

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 communicates the core functionality without unnecessary words. It's appropriately sized for a search tool and front-loads the essential information. Every word earns its place in this concise statement.

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?

For a search tool with 4 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain what kind of results to expect, how citation data is presented, or how this tool differs from the many other search tools available. The lack of behavioral context and usage guidance leaves significant gaps for an AI agent trying to use this tool 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%, so the schema already documents all 4 parameters thoroughly. The description doesn't add any parameter-specific information beyond what's in the schema descriptions. It mentions 'citation data' which relates to output rather than input parameters. Baseline score of 3 is appropriate when schema does the heavy lifting.

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') and resource ('Semantic Scholar for academic papers'), and specifies the type of data returned ('with citation data'). However, it doesn't explicitly differentiate this tool from its many sibling search tools (e.g., search_arxiv, search_pubmed) beyond mentioning Semantic Scholar specifically.

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 no guidance on when to use this tool versus the many alternative search tools available on the server (search_arxiv, search_pubmed, search_google_scholar, etc.). There's no mention of Semantic Scholar's specific strengths, coverage, or when it might be preferred over other academic search tools.

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/Dianel555/paper-search-mcp-nodejs'

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