How can I connect an MCP server to the playground server and not use terminator?

Even though I can talk on the playground, the MCP server doesn’t connect.

from agno.agent import Agent
from agno.models.openrouter import OpenRouter
from agno.playground import Playground, serve_playground_app
from agno.storage.sqlite import SqliteStorage
from agno.tools.mcp import MCPTools
from mcp import StdioServerParameters
from textwrap import dedent

Storage path for agent sessions

agent_storage: str = “tmp/agents.db”

Create the MCP tool using the command parameter directly

server_params = StdioServerParameters(
command=“npx”,
args=[
“-y”,
@bytebase/dbhub”,
“–transport”, “stdio”,
“–dsn”, “”
],
)

Instantiate the MCP tool

mcp_tools = MCPTools(server_params=server_params)

Create the agent

postgres_agent = Agent(
name=“PostgreSQL Assistant”,
model=OpenRouter(
id=“google/gemini-2.0-flash-exp:free”,
api_key=“”
),
tools=[mcp_tools],
instructions=dedent(“”"
You are an expert PostgreSQL database assistant. Help users explore and query the database.

  • Respond clearly and in detail in Spanish.
  • Use available tools to access the database.
  • Provide relevant context about the queries you have made.
  • Organize your answers with headings when appropriate.
  • Be concise and focus on relevant information.
    “”),
    storage=SqliteStorage(table_name=“postgres_agent”, db_file=agent_storage),
    add_datetime_to_instructions=True,
    add_history_to_messages=True,
    num_history_responses=5,
    markdown=True,
    show_tool_calls=True,

)

Create the app to interact with the agent

app = Playground(agents=[postgres_agent]).get_app()

Start the server

if name == “main”:
serve_playground_app(“agent_postgre:app”, reload=True)

Hi @Jhosep
,thanks for reaching out and supporting Agno!We’ve shared this with the team and are working through requests one by one—we’ll get back to you as soon as we can.We’ve just kicked off the Global Agent Hackathon , so things are a bit busier than usual. If you’re up for it, we’d love for you to join—it’s a great chance to build, win some exciting prizes and connect with the agent community!If it’s urgent, just let us know. Thanks for your patience!

1 Like

Hey Jhosep — welcome! You might find this helpful: mcp_demo.py cookbook. It walks through connecting MCP to Playground. Hope it helps, Let us know how it goes!

1 Like

It’s okay, don’t worry. I think it’s an incredible tool, AGNO. I’m continuing to study to use it better.
Thank you for your help.

Thank you very much, I will review and try it, and I will let you know how it goes with the example you provided.

1 Like