Skip to main content
Glama

Semantic Scholar MCP Server

semantic_scholar_search.cpython-310.pyc2.56 kB
o Ar�g� � @s�ddlZddlmZmZmZddlmZmZmZdefdd�Z dded e d e deee effd d �Z ded e defdd�Z dede defdd�Zdedee eee efffdd�Zdd�Zedkrie�dSdS)�N)�SemanticScholar�Author�Paper)�List�Dict�Any�returncCst�S)z&Initialize the SemanticScholar client.N)r�r r �N/home/zjlab/code/mcp_hub/semanticscholar-MCP-Server/semantic_scholar_search.py�initialize_clientsr � �client�query�limitcCs|j||d�}dd�|D�S)z'Search for papers using a query string.)rc Ss@g|]}|j|j|j|jdd�|jD�|j|j|j|jd� �qS)cSsg|] }|j|jd��qS)��name�authorIdr)�.0�authorr r r � <listcomp>sz,search_papers.<locals>.<listcomp>.<listcomp>� �paperId�title�abstract�year�authors�url�venue�publicationTypes� citationCountr)r�paperr r r r s ���z!search_papers.<locals>.<listcomp>N)� search_paper)r rr�resultsr r r � search_papers s �r#�paper_idcC� |�|�S)z Get details of a specific paper.N)� get_paper)r r$r r r �get_paper_details� r'� author_idcCr%)z!Get details of a specific author.N)� get_author)r r)r r r �get_author_detailsr(r+r cCs|j|jd�S)z)Get citations and references for a paper.�� citations� referencesNr,)r r r r �get_citations_and_references"s�r/c Cs�zVt�}t|d�}td|dd����|rF|dd}t||�}td|���t|�}td|ddd����td |d dd����d }t||�}td |���WdStjyq}ztd |���WYd}~dSd}~ww)Nzmachine learningzSearch results: �rrzPaper details: z Citations: r-z References: r.Z1741101zAuthor details: zAn error occurred: )r r#�printr'r/r+�sch�SemanticScholarException)r Zsearch_resultsr$r �citations_refsr)r�er r r �main)s$    ��r6�__main__)r )�semanticscholarr2rrr�typingrrrr �str�intr#r'r+r/r6�__name__r r r r �<module>s(& �

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/JackKuo666/semanticscholar-MCP-Server'

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