Skip to main content
Use multiple MCP servers in a single agent.
include_exclude_tools.py

Run the Example

1

Set up your virtual environment

2

Install dependencies

3

Prepare Node.js

The MCP server runs with npx. Install Node.js, then verify the commands:
4

Export your OpenAI API key

5

Review the source limitation

This example does not pass GOOGLE_MAPS_API_KEY to the Google Maps MCP server, and include_tools=["airbnb_search"] filters out every Maps tool. Correct both settings before running the restaurant query.
6

Update the sample times

Replace the August 2025 Airbnb dates with future dates and replace right now with an explicit local date and time.
7

Run the example

Save the code above as include_exclude_tools.py, then run:
Full source: cookbook/91_tools/mcp/include_exclude_tools.py