Version: 0.1.0
Last Update: 2025/06/05
MCP Support
Python Calling Support
Search the web for any questions and knowledge and obtain a concise answer based on thesearch results.
Example
Input:
query: 'What is the boiling point of water?'
Text Input (used for the run_text
function in the Python calling mode):
query: 'What is the boiling point of water?'
Output:
'The boiling point of water at sea level is 100°C (212°F).'
Usage
The tool supports both MCP mode and Python calling mode.
Environment Variables
This tool requires the following environment variables:
- TAVILY_API_KEY: The API key for Tavily.
MCP Mode
Configure your MCP client following its instructions with something like:
{
"command": "/ABSTRACT/PATH/TO/uv", // Use `which uv` to get its path
"args": ["--directory", "/ABSTRACT/PATH/TO/ChemMCP", "run", "--tools", "WebSearch"],
"toolCallTimeoutMillis": 300000,
"env": {
"TAVILY_API_KEY": "VALUE_TO_BE_SET"
}
}
Python Calling Mode
import os
from chemmcp.tools import WebSearch
# Set the environment variables
os.environ['TAVILY_API_KEY'] = 'VALUE_TO_BE_SET'
# Initialize the tool
tool = WebSearch()
# The tool has two alternative ways to run:
# 1. Run with separate input domains (recommended)
output = tool.run_code(
query='What is the boiling point of water?'
)
# 2. Run with text-only input
output = tool.run_text(
query='What is the boiling point of water?'
)
Each tool in ChemMCP has two ways to run:
run_code
(recommended): The inputs contain one or more domains, each of which can be a str, an int, a float, etc.run_text
: The inputs are a single string in a specific format. The tool will parse the string to extract the input domains. This is useful in scenarios where an agent framework calls tools only with text input. The output is the same in both cases.
For the input and output domains, please refer to the tool’s signature.
Tool Signature
Input
Used in the MCP mode, as well as the run_code
function in the Python calling mode.
Name | Type | Default | Description |
---|---|---|---|
query | str | N/A | The search query. |
Text Input
Used in the run_text
function in the Python calling mode.
Name | Type | Default | Description |
---|---|---|---|
query | str | N/A | The search query. |
Output
The output is the same in both input cases.
Name | Type | Description |
---|---|---|
result | str | The answer to the search query summarized by Tavily’s LLM. |
Envs
Name | Description |
---|---|
TAVILY_API_KEY | The API key for Tavily. |