import asyncio
import logging
from pydantic_ai import Agent
from pydantic_ai.mcp import MCPServerHTTP # Corrected import path
from dotenv import load_dotenv
load_dotenv()
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger("MCP_TEST")
async def test_pydantic_mcp():
"""Test Pydantic AI MCP integration with sanitized server."""
logger.info("Testing Pydantic AI MCP integration")
mcp_server = MCPServerHTTP(url="MCP_ENDPOINT") # Change to your MCP endpoint
agent = Agent(
"openai:gpt-4o-mini",
system_prompt="You are a helpful assistant that can answer questions and help with tasks.",
mcp_servers=[mcp_server]
)
user_query = "Quiero saber que eventos hay en berghain para marzo del 2025"
async with agent.run_mcp_servers():
logger.info(f"Executing query: {user_query}")
result = await agent.run(user_query)
print(result)
logger.info(f"Got result: {result.output}")
async def main():
await test_pydantic_mcp()
if __name__ == "__main__":
asyncio.run(main())
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/alejofig/mcp-berghain'
If you have feedback or need assistance with the MCP directory API, please join our Discord server