### Example of Improved Tool Description with Query Example Source: https://github.com/yliust/mcp-testing/blob/master/README.md This Python function demonstrates how to refine a tool's description by embedding a clear query example within its docstring. The 'search_pubchem_by_name' function's docstring now includes details on arguments, return types, and a concrete 'Query example' to guide users. ```python def search_pubchem_by_name(): """ Search PubChem for compounds matching a chemical name. Args: name: The chemical name to search for **kwargs: Additional parameters for the API request (e.g., max_records: int) Query example: { "name": "aspirin", "kwargs": {} } Returns: Dictionary containing search results with compounds that match the name """ pass ``` -------------------------------- ### Install Python Dependencies for Langchain MCP Adapters Source: https://github.com/yliust/mcp-testing/blob/master/README.md This snippet shows how to install the necessary Python package 'langchain_mcp_adapters' using pip, which is required to interact with Multi-Server MCP clients. ```bash pip install langchain_mcp_adapters ``` -------------------------------- ### Invoke PubChem Search Tool with Example Query Source: https://github.com/yliust/mcp-testing/blob/master/README.md This Python code demonstrates how to invoke the 'search_pubchem_by_name' tool with a sample query for 'aspirin'. It shows how to structure the 'query_args' dictionary and use 'tool.ainvoke' to execute the tool, verifying its functionality based on its clear description. ```python query_args = { "name": "aspirin", # Name of the compound "kwargs": {} # other parameters, can be set to an empty dict } result = await tool.ainvoke(query_args) print(result) ``` -------------------------------- ### Example of Clear Tool Description Retrieval Source: https://github.com/yliust/mcp-testing/blob/master/README.md This Python snippet illustrates how to retrieve and display the description and argument schema for a tool ('gsea_search') that has a clear and comprehensive description. The detailed output (not shown in code) typically includes the tool's function, query format, example usage, and explicit arguments, making it easy to understand and use. ```python tool_name = 'gsea_search' tool = tool_map.get(tool_name) show_tool_description(tool) ``` -------------------------------- ### Example of Unclear Tool Description Retrieval Source: https://github.com/yliust/mcp-testing/blob/master/README.md This Python snippet demonstrates how to retrieve and display the description and argument schema for a tool ('get_activity') that has an unclear description. The accompanying output (not shown in code) typically reveals a vague description and an empty argument schema, making it difficult to understand the tool's purpose or usage. ```python tool_name = 'get_activity' tool = tool_map.get(tool_name) show_tool_description(tool) ``` -------------------------------- ### Connect to MCP Client and Retrieve Tool Descriptions Source: https://github.com/yliust/mcp-testing/blob/master/README.md This Python code demonstrates how to connect to a Multi-Server MCP client, retrieve a list of available tools, and then display the description and argument schema for a specific tool (e.g., 'get_cell_line_by_id'). It highlights how to access 'tool.description' and 'tool.args_schema'. ```python import asyncio from langchain_mcp_adapters.client import MultiServerMCPClient mcp_servers = {} # 连接mcp服务 client = MultiServerMCPClient(mcp_servers) tools = await client.get_tools() print(f"✅ 成功连接!发现 {len(tools)} 个工具:") # 获取工具名称到工具的映射 tool_map = {tool.name: tool for tool in tools} # 指定tool的name tool_name = 'get_cell_line_by_id' tool = tool_map.get(tool_name) assert tool is not None, f"Tool {tool_name} not found!" # 获取tool的description等信息 def show_tool_description(tool): print(f'Tool Name: {tool.name}\n') print('=' * 5, ' Tool Description ', '=' * 5) print(tool.description, '\n') print('=' * 5, ' Input Args Schema ', '=' * 5) print(tool.args_schema, '\n') show_tool_description(tool) ``` -------------------------------- ### Display Description for PubChem Search Tool Source: https://github.com/yliust/mcp-testing/blob/master/README.md This Python snippet retrieves and displays the description and argument schema for the 'search_pubchem_by_name' tool from the PubChem database. It serves as a prerequisite for demonstrating how to test a clearly described tool. ```python tool_name = 'search_pubchem_by_name' tool = tool_map.get(tool_name) show_tool_description(tool) ``` -------------------------------- ### External API Documentation Links for MCP Tools Source: https://github.com/yliust/mcp-testing/blob/master/README.md This section provides direct links to the original API documentation for various Multi-Server MCP tool packages, including Chembl, KEGG, PubChem, and String. These links are crucial for understanding tools with unclear internal descriptions. ```APIDOC chembl_mcp API Documentation: https://www.ebi.ac.uk/chembl/api/data/docs kegg_mcp API Documentation: https://rest.kegg.jp pubchem_mcp API Documentation: https://pubchemdocs.ncbi.nlm.nih.gov/programmatic-access string_mcp API Documentation: https://version-12-0.string-db.org/cgi/help?sessionId=bJAGYvuWb0TA ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.