> For the complete documentation index, see [llms.txt](https://docs.ibexa.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ibexa.ai/developers/rest-api/agents/link-mcp-server.md).

# Link Mcp Server

Link an MCP server to an agent with specified enabled tools.

Creates or updates the link between an agent and an MCP server. The enabled\_tools list specifies which tools from the MCP server should be available to this agent.

Users can only link MCP servers to agents they created, and both the agent and MCP server must be in the user's organisation.

```json
{"openapi":"3.1.0","info":{"title":"Ibexa Agentic Marketing Platform","version":"0.1.0"},"security":[{"OAuth2PasswordBearer":[]}],"components":{"securitySchemes":{"OAuth2PasswordBearer":{"type":"oauth2","flows":{"password":{"scopes":{},"tokenUrl":"/api/v1/login/access-token"}}}},"schemas":{"LinkMCPServerPayloadSchema":{"properties":{"enabled_tools":{"items":{"type":"string"},"type":"array","title":"Enabled Tools","description":"List of tool names to enable for this agent-server link"}},"type":"object","title":"LinkMCPServerPayloadSchema","description":"Pydantic schema for linking an MCP server to an agent."},"AgentMCPServerLinkResponseSchema":{"properties":{"mcp_server_id":{"type":"integer","title":"Mcp Server Id"},"enabled_tools":{"items":{"type":"string"},"type":"array","title":"Enabled Tools"}},"type":"object","required":["mcp_server_id","enabled_tools"],"title":"AgentMCPServerLinkResponseSchema","description":"Pydantic schema for agent-MCP server link response."}}},"paths":{"/api/v1/agents/{agent_id}/mcp-servers/{server_id}":{"put":{"tags":["agents","public"],"summary":"Link Mcp Server","description":"Link an MCP server to an agent with specified enabled tools.\n\nCreates or updates the link between an agent and an MCP server.\nThe enabled_tools list specifies which tools from the MCP server\nshould be available to this agent.\n\nUsers can only link MCP servers to agents they created, and both\nthe agent and MCP server must be in the user's organisation.","operationId":"agents-link_mcp_server","parameters":[{"name":"agent_id","in":"path","required":true,"schema":{"type":"integer","title":"Agent Id"}},{"name":"server_id","in":"path","required":true,"schema":{"type":"integer","title":"Server Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LinkMCPServerPayloadSchema"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AgentMCPServerLinkResponseSchema"}}}},"400":{"description":"Invalid request payload or parameters","content":{"application/json":{}}},"401":{"description":"User not authenticated","content":{"application/json":{}}},"403":{"description":"User lacks permission","content":{"application/json":{}}},"404":{"description":"Resource not found or user has no permission to access it","content":{"application/json":{}}}}}}}}
```
