Back to Smithery

Create or update connection

docs-api-reference-connect-create-or-update-connection.md

latest16.0 KB
Original Source

PUT

/

connect

/

{namespace}

/

{connectionId}

Try it

Create or update connection

cURL

curl --request PUT \
  --url https://api.smithery.ai/connect/{namespace}/{connectionId} \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "transport": "http",
  "mcpUrl": "https://mcp.example.com/sse",
  "server": "upstash/context7-mcp",
  "name": "My MCP Server",
  "metadata": {
    "userId": "user123",
    "team": "engineering"
  },
  "headers": {
    "X-API-Key": "secret-key"
  },
  "mock": {
    "enabled": true
  }
}
'
import requests

url = "https://api.smithery.ai/connect/{namespace}/{connectionId}"

payload = {
    "transport": "http",
    "mcpUrl": "https://mcp.example.com/sse",
    "server": "upstash/context7-mcp",
    "name": "My MCP Server",
    "metadata": {
        "userId": "user123",
        "team": "engineering"
    },
    "headers": { "X-API-Key": "secret-key" },
    "mock": { "enabled": True }
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.put(url, json=payload, headers=headers)

print(response.text)
const options = {
  method: 'PUT',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: JSON.stringify({
    transport: 'http',
    mcpUrl: 'https://mcp.example.com/sse',
    server: 'upstash/context7-mcp',
    name: 'My MCP Server',
    metadata: {userId: 'user123', team: 'engineering'},
    headers: {'X-API-Key': 'secret-key'},
    mock: {enabled: true}
  })
};

fetch('https://api.smithery.ai/connect/{namespace}/{connectionId}', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.smithery.ai/connect/{namespace}/{connectionId}",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "PUT",
  CURLOPT_POSTFIELDS => json_encode([
    'transport' => 'http',
    'mcpUrl' => 'https://mcp.example.com/sse',
    'server' => 'upstash/context7-mcp',
    'name' => 'My MCP Server',
    'metadata' => [
        'userId' => 'user123',
        'team' => 'engineering'
    ],
    'headers' => [
        'X-API-Key' => 'secret-key'
    ],
    'mock' => [
        'enabled' => true
    ]
  ]),
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer <token>",
    "Content-Type: application/json"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.smithery.ai/connect/{namespace}/{connectionId}"

	payload := strings.NewReader("{\n \"transport\": \"http\",\n \"mcpUrl\": \"https://mcp.example.com/sse\",\n \"server\": \"upstash/context7-mcp\",\n \"name\": \"My MCP Server\",\n \"metadata\": {\n \"userId\": \"user123\",\n \"team\": \"engineering\"\n },\n \"headers\": {\n \"X-API-Key\": \"secret-key\"\n },\n \"mock\": {\n \"enabled\": true\n }\n}")

	req, _ := http.NewRequest("PUT", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.put("https://api.smithery.ai/connect/{namespace}/{connectionId}")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n \"transport\": \"http\",\n \"mcpUrl\": \"https://mcp.example.com/sse\",\n \"server\": \"upstash/context7-mcp\",\n \"name\": \"My MCP Server\",\n \"metadata\": {\n \"userId\": \"user123\",\n \"team\": \"engineering\"\n },\n \"headers\": {\n \"X-API-Key\": \"secret-key\"\n },\n \"mock\": {\n \"enabled\": true\n }\n}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://api.smithery.ai/connect/{namespace}/{connectionId}")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"transport\": \"http\",\n \"mcpUrl\": \"https://mcp.example.com/sse\",\n \"server\": \"upstash/context7-mcp\",\n \"name\": \"My MCP Server\",\n \"metadata\": {\n \"userId\": \"user123\",\n \"team\": \"engineering\"\n },\n \"headers\": {\n \"X-API-Key\": \"secret-key\"\n },\n \"mock\": {\n \"enabled\": true\n }\n}"

response = http.request(request)
puts response.read_body

200

201

400

404

409

{
  "connectionId": "clever-dolphin-a9X3",
  "name": "<string>",
  "mcpUrl": "<string>",
  "metadata": {},
  "transport": "http",
  "mock": {
    "enabled": true,
    "scenario": "Slack workspace with an active #community-ops channel containing recent event-planning messages, plus 50 Airtable candidate records with mixed tenure and interests."
  },
  "iconUrl": "<string>",
  "createdAt": "<string>",
  "status": {
    "state": "connected"
  },
  "serverInfo": {
    "name": "<string>",
    "version": "<string>",
    "title": "<string>",
    "icons": [
      {
        "src": "<string>",
        "mimeType": "<string>",
        "sizes": [
          "<string>"
        ],
        "theme": "light"
      }
    ],
    "websiteUrl": "<string>",
    "description": "<string>"
  }
}
{
  "connectionId": "clever-dolphin-a9X3",
  "name": "<string>",
  "mcpUrl": "<string>",
  "metadata": {},
  "transport": "http",
  "mock": {
    "enabled": true,
    "scenario": "Slack workspace with an active #community-ops channel containing recent event-planning messages, plus 50 Airtable candidate records with mixed tenure and interests."
  },
  "iconUrl": "<string>",
  "createdAt": "<string>",
  "status": {
    "state": "connected"
  },
  "serverInfo": {
    "name": "<string>",
    "version": "<string>",
    "title": "<string>",
    "icons": [
      {
        "src": "<string>",
        "mimeType": "<string>",
        "sizes": [
          "<string>"
        ],
        "theme": "light"
      }
    ],
    "websiteUrl": "<string>",
    "description": "<string>"
  }
}
{
  "error": "validation_error",
  "message": "Invalid request"
}
{
  "error": "not_found",
  "message": "Resource not found"
}
{
  "error": "not_found",
  "message": "Resource not found"
}

Authorizations

[​

](#authorization-authorization)

Authorization

string

header

required

Smithery API key as Bearer token

Path Parameters

[​

](#parameter-namespace)

namespace

string

required

[​

](#parameter-connection-id)

connectionId

string

required

Body

application/json

[​

](#body-transport)

transport

enum<string>

Connection transport. Defaults to the existing connection transport when updating.

Available options: http,

uplink

Example:

"http"

[​

](#body-mcp-url)

mcpUrl

string<uri>

URL of a custom MCP server. For Smithery registry servers, prefer server. Required with server omitted when creating a new HTTP connection; optional when updating.

Example:

"https://mcp.example.com/sse"

[​

](#body-server)

server

string

Smithery registry server qualified name. Use this instead of mcpUrl for registry servers.

Required string length: 1 - 255

Pattern: ^@?[a-zA-Z0-9][a-zA-Z0-9_-]*(?:\/[a-zA-Z0-9][a-zA-Z0-9_-]*)?$

Example:

"upstash/context7-mcp"

[​

](#body-source)

source

object

Show child attributes

[​

](#body-name)

name

string

Human-readable name (optional, defaults to connection ID)

Required string length: 1 - 255

Example:

"My MCP Server"

[​

](#body-metadata)

metadata

object

Custom metadata for filtering connections

Show child attributes

Example:

`{ "userId": "user123", "team": "engineering"}`

[​

](#body-headers)

headers

object

Custom headers to send with MCP requests (stored securely, not returned in responses)

Show child attributes

Example:

`{ "X-API-Key": "secret-key" }`

[​

](#body-mock)

mock

object

Run this connection in mock mode. Only honored on first creation; ignored on updates to an existing connection.

Show child attributes

Example:

`{ "enabled": true }`

Response

200

application/json

Connection updated

[​

](#response-connection-id)

connectionId

string

required

Connection ID (auto-generated or developer-defined)

Example:

"clever-dolphin-a9X3"

[​

](#response-name)

name

string

required

Human-readable name

[​

](#response-mcp-url-one-of-0)

mcpUrl

string | null

required

MCP server URL. Null for uplink connections.

[​

](#response-metadata-one-of-0)

metadata

object | null

required

Show child attributes

[​

](#response-transport)

transport

enum<string>

Connection transport

Available options: http,

uplink

[​

](#response-mock)

mock

object

Mock-mode config: {enabled: true, scenario?} when LLM-simulated, absent otherwise.

Show child attributes

[​

](#response-icon-url-one-of-0)

iconUrl

string | null

[​

](#response-created-at)

createdAt

string

ISO 8601 timestamp

[​

](#response-status)

status

ConnectionStatusConnected · object

Last known connection status

ConnectionStatusConnected

ConnectionStatusDisconnected

ConnectionStatusAuthRequired

ConnectionStatusInputRequired

ConnectionStatusError

Show child attributes

[​

](#response-server-info)

serverInfo

object

Server information from MCP initialization (name, version)

Show child attributes

Was this page helpful?

YesNo

⌘I

Create or update connection

cURL

curl --request PUT \
  --url https://api.smithery.ai/connect/{namespace}/{connectionId} \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "transport": "http",
  "mcpUrl": "https://mcp.example.com/sse",
  "server": "upstash/context7-mcp",
  "name": "My MCP Server",
  "metadata": {
    "userId": "user123",
    "team": "engineering"
  },
  "headers": {
    "X-API-Key": "secret-key"
  },
  "mock": {
    "enabled": true
  }
}
'
import requests

url = "https://api.smithery.ai/connect/{namespace}/{connectionId}"

payload = {
    "transport": "http",
    "mcpUrl": "https://mcp.example.com/sse",
    "server": "upstash/context7-mcp",
    "name": "My MCP Server",
    "metadata": {
        "userId": "user123",
        "team": "engineering"
    },
    "headers": { "X-API-Key": "secret-key" },
    "mock": { "enabled": True }
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.put(url, json=payload, headers=headers)

print(response.text)
const options = {
  method: 'PUT',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: JSON.stringify({
    transport: 'http',
    mcpUrl: 'https://mcp.example.com/sse',
    server: 'upstash/context7-mcp',
    name: 'My MCP Server',
    metadata: {userId: 'user123', team: 'engineering'},
    headers: {'X-API-Key': 'secret-key'},
    mock: {enabled: true}
  })
};

fetch('https://api.smithery.ai/connect/{namespace}/{connectionId}', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.smithery.ai/connect/{namespace}/{connectionId}",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "PUT",
  CURLOPT_POSTFIELDS => json_encode([
    'transport' => 'http',
    'mcpUrl' => 'https://mcp.example.com/sse',
    'server' => 'upstash/context7-mcp',
    'name' => 'My MCP Server',
    'metadata' => [
        'userId' => 'user123',
        'team' => 'engineering'
    ],
    'headers' => [
        'X-API-Key' => 'secret-key'
    ],
    'mock' => [
        'enabled' => true
    ]
  ]),
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer <token>",
    "Content-Type: application/json"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.smithery.ai/connect/{namespace}/{connectionId}"

	payload := strings.NewReader("{\n \"transport\": \"http\",\n \"mcpUrl\": \"https://mcp.example.com/sse\",\n \"server\": \"upstash/context7-mcp\",\n \"name\": \"My MCP Server\",\n \"metadata\": {\n \"userId\": \"user123\",\n \"team\": \"engineering\"\n },\n \"headers\": {\n \"X-API-Key\": \"secret-key\"\n },\n \"mock\": {\n \"enabled\": true\n }\n}")

	req, _ := http.NewRequest("PUT", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.put("https://api.smithery.ai/connect/{namespace}/{connectionId}")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n \"transport\": \"http\",\n \"mcpUrl\": \"https://mcp.example.com/sse\",\n \"server\": \"upstash/context7-mcp\",\n \"name\": \"My MCP Server\",\n \"metadata\": {\n \"userId\": \"user123\",\n \"team\": \"engineering\"\n },\n \"headers\": {\n \"X-API-Key\": \"secret-key\"\n },\n \"mock\": {\n \"enabled\": true\n }\n}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://api.smithery.ai/connect/{namespace}/{connectionId}")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"transport\": \"http\",\n \"mcpUrl\": \"https://mcp.example.com/sse\",\n \"server\": \"upstash/context7-mcp\",\n \"name\": \"My MCP Server\",\n \"metadata\": {\n \"userId\": \"user123\",\n \"team\": \"engineering\"\n },\n \"headers\": {\n \"X-API-Key\": \"secret-key\"\n },\n \"mock\": {\n \"enabled\": true\n }\n}"

response = http.request(request)
puts response.read_body

200

201

400

404

409

{
  "connectionId": "clever-dolphin-a9X3",
  "name": "<string>",
  "mcpUrl": "<string>",
  "metadata": {},
  "transport": "http",
  "mock": {
    "enabled": true,
    "scenario": "Slack workspace with an active #community-ops channel containing recent event-planning messages, plus 50 Airtable candidate records with mixed tenure and interests."
  },
  "iconUrl": "<string>",
  "createdAt": "<string>",
  "status": {
    "state": "connected"
  },
  "serverInfo": {
    "name": "<string>",
    "version": "<string>",
    "title": "<string>",
    "icons": [
      {
        "src": "<string>",
        "mimeType": "<string>",
        "sizes": [
          "<string>"
        ],
        "theme": "light"
      }
    ],
    "websiteUrl": "<string>",
    "description": "<string>"
  }
}
{
  "connectionId": "clever-dolphin-a9X3",
  "name": "<string>",
  "mcpUrl": "<string>",
  "metadata": {},
  "transport": "http",
  "mock": {
    "enabled": true,
    "scenario": "Slack workspace with an active #community-ops channel containing recent event-planning messages, plus 50 Airtable candidate records with mixed tenure and interests."
  },
  "iconUrl": "<string>",
  "createdAt": "<string>",
  "status": {
    "state": "connected"
  },
  "serverInfo": {
    "name": "<string>",
    "version": "<string>",
    "title": "<string>",
    "icons": [
      {
        "src": "<string>",
        "mimeType": "<string>",
        "sizes": [
          "<string>"
        ],
        "theme": "light"
      }
    ],
    "websiteUrl": "<string>",
    "description": "<string>"
  }
}
{
  "error": "validation_error",
  "message": "Invalid request"
}
{
  "error": "not_found",
  "message": "Resource not found"
}
{
  "error": "not_found",
  "message": "Resource not found"
}