---
title: "03: Static Tool Filtering with MCPServerStreamableHttp"
source: Panaversity Learn Agentic AI
source_url: https://github.com/panaversity/learn-agentic-ai
licence: Apache-2.0
domain: agentic-ai
subdomain: panaversity-agentic
date_added: 2026-04-25
---

# 03: Static Tool Filtering with MCPServerStreamableHttp

## What Are We Learning? (The “Why”)

In this step, you’re learning **how to control which tools your agent can see and use** from an MCP server. This is a foundational skill for building safe, focused, and user-friendly agentic systems.

- **Why is this important?**
  - Sometimes, an MCP server might offer many tools, but you only want your agent to use a few of them for a specific task or user.
  - Filtering tools helps you avoid mistakes, reduce confusion, and keep your agent’s capabilities clear and safe.
  - This is a “baby step” toward more advanced agent control—starting with simple allow/block lists before moving to dynamic, context-aware filtering.

## What’s the Big Idea?

- **Static tool filtering** means you decide up front (in your code) which tools are allowed or blocked.
- You do this by passing a filter to your MCP server client.
- This filter acts like a “menu” for your agent: only the items you approve are visible.

## How Does It Work? (The “How”)

1. **You import a helper function** to create your filter.
2. **You tell the MCP server client** which tools to allow or block.
3. **When your agent connects**, it only sees the tools you’ve chosen.

## Step-by-Step Example

```python
from agents.mcp import MCPServerStreamableHttp, MCPServerStreamableHttpParams, create_static_tool_filter

# Only allow the "mood_from_shared_server" tool
tool_filter = create_static_tool_filter(allowed_tool_names=["mood_from_shared_server"])
mcp_params = MCPServerStreamableHttpParams(url="http://localhost:8001/mcp/")

async with MCPServerStreamableHttp(params=mcp_params, tool_filter=tool_filter, name="MyFilteredMCPServer") as mcp_server_client:
    # ... set up your agent and run as before ...
```

- Now, if you list tools or run the agent, it will only see and use `mood_from_shared_server`.

## What Should You Notice?

- If you try to use a tool that’s not allowed, the agent won’t see it.
- This is a simple, reliable way to “baby-proof” your agent’s toolbox.

## Why Is This a Good Learning Step?

- **It’s safe:** You can experiment without risk—your agent can’t use tools you haven’t approved.
- **It’s clear:** You see exactly which tools are available, making debugging and learning easier.
- **It’s foundational:** This prepares you for more advanced filtering (like dynamic, context-aware filters) in the next steps.

---

**In summary:**  
You’re learning how to give your agent a carefully chosen set of tools, just like giving a child safe toys to play with. This is a key building block for safe, scalable, and maintainable agentic systems.

---
