Connecting an external MCP server to MCP Hub
Note
This feature is at the Preview stage.
If you already have deployed an external MCP server, e.g., on smithery.ai
To add an existing external MCP server to MCP Hub:
-
In the management console
, select a folder for which your account has theserverless.mcpGateways.editorandserverless.mcpGateways.anonymousInvokerroles or higher. -
In the list of services, select AI Studio.
-
In the left-hand panel, select MCP servers and click Create MCP server. In the window that opens, do the following:
-
Under Add Method, select
Connect. -
Under Tools, click Add tools and in the window that opens:
-
In the Transport field, select a transport method for communicating with the MCP server. Available types:
- HTTP Stream
is the latest state-of-art transport mechanism. Your AI agent will be able to get updates (events) from the server without a persistent HTTP connection. - SSE
is a legacy transport mechanism. Your AI agent will be able to get updates from the server over the same persistent HTTP connection.
- HTTP Stream
-
In the URL field, specify a URL for accessing the MCP server, e.g.,
https://mcp.example.com. -
In the Authorization type field, specify the authentication data to provide in requests:
-
Access token: To provide the access token in the request authorization header.To add additional headers to the request, click
Add header. -
Without authorization: To skip authentication.
-
-
Click Connect.
-
In the Add tools window that opens, select the tools from the template to add to the new MCP server and click Add.
Note
One MCP server can contain up to 50 tools.
-
-
Under Server parameters:
-
In the Name field, enter a name for the new MCP server. Follow these naming requirements:
- It must be from 2 to 63 characters long.
- It can only contain lowercase Latin letters, numbers, and hyphens.
- It must start with a letter and cannot end with a hyphen.
-
Optionally, add a description and labels for the server you are creating by using the corresponding buttons.
-
In the Access field, select the server type:
- Private: To build a private MCP server with the authentication-based access.
- Public: To build a public MCP server that requires no authentication.
-
In the Service account field, select the service account your MCP server will use to access Yandex Cloud services and resources. The service account should get the roles sufficient to access these resources and services.
-
Optionally, enable Specify network to specify a cloud network to host your MCP server instances.
-
Optionally, turn on the Enable logging option and configure the logging settings to keep a log of the MCP server you are creating.
-
-
Click Save.
-
This will create an MCP server in MCP Hub, containing the added tools and accessible to AI agents.
Using the Responses API to access an external MCP server
Instead of MCP Hub, you can use the Responses API to access an external MCP server from an AI agent. To do this, simply specify the server URL and the API key.
Example of connecting an MCP server via the Responses API:
from openai import OpenAI
# Creating a client
client = openai.OpenAI(
api_key="<API_key>",
base_url="https://rest-assistant.api.cloud.yandex.net/v1",
project="<folder_ID>"
)
# Example of calling the MCP via the Responses API
response = client.responses.create(
model="gpt://<folder_ID>/yandexgpt",
input=[
{
"role": "user",
"content": "Find a client named John Doe in your CRM"
}
],
# MCP tools, available models
tools=[
{
"server_label": "crm_lookup",
"server_url": "<MCP_server_URL>",
"type": "mcp",
"metadata": {
"description": "Client search in CRM by name"
}
}
]
)
print(response.output_text)