Back to Smithery

Create a server

docs-api-reference-servers-create-a-server.md

latest7.4 KB
Original Source

PUT

/

servers

/

{qualifiedName}

Try it

JavaScript

JavaScript

import Smithery from '@smithery/api';

const client = new Smithery({
  apiKey: process.env['SMITHERY_API_KEY'], // This is the default and can be omitted
});

const server = await client.servers.create('qualifiedName');

console.log(server.createdAt);
curl --request PUT \
  --url https://api.smithery.ai/servers/{qualifiedName} \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "displayName": "My Server",
  "description": "A simple server"
}
'
import requests

url = "https://api.smithery.ai/servers/{qualifiedName}"

payload = {
    "displayName": "My Server",
    "description": "A simple server"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.text)
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.smithery.ai/servers/{qualifiedName}",
  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([
    'displayName' => 'My Server',
    'description' => 'A simple server'
  ]),
  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/servers/{qualifiedName}"

	payload := strings.NewReader("{\n \"displayName\": \"My Server\",\n \"description\": \"A simple server\"\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/servers/{qualifiedName}")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n \"displayName\": \"My Server\",\n \"description\": \"A simple server\"\n}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://api.smithery.ai/servers/{qualifiedName}")

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 \"displayName\": \"My Server\",\n \"description\": \"A simple server\"\n}"

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

201

400

401

403

404

{
  "namespace": "myorg",
  "server": "",
  "displayName": "My Server",
  "description": "A simple server",
  "createdAt": "2024-01-01T00:00:00.000Z"
}
{
  "error": "Server not found"
}
{
  "error": "Server not found"
}
{
  "error": "Server not found"
}
{
  "error": "Server not found"
}

Authorizations

[​

](#authorization-authorization)

Authorization

string

header

required

Smithery API key as Bearer token

Path Parameters

[​

](#parameter-qualified-name)

qualifiedName

string

required

The server's qualified name (e.g. 'namespace/server' or 'namespace' for namespace-only servers). Use %2F to encode the slash.

Body

application/json

[​

](#body-display-name)

displayName

string

Example:

"My Server"

[​

](#body-description)

description

string

Example:

"A simple server"

Response

201

application/json

Server created successfully

[​

](#response-namespace)

namespace

string

required

Example:

"myorg"

[​

](#response-server)

server

string

required

Example:

""

[​

](#response-display-name)

displayName

string

required

Example:

"My Server"

[​

](#response-description)

description

string

required

Example:

"A simple server"

[​

](#response-created-at)

createdAt

string

required

Example:

"2024-01-01T00:00:00.000Z"

Was this page helpful?

YesNo

⌘I

JavaScript

JavaScript

import Smithery from '@smithery/api';

const client = new Smithery({
  apiKey: process.env['SMITHERY_API_KEY'], // This is the default and can be omitted
});

const server = await client.servers.create('qualifiedName');

console.log(server.createdAt);
curl --request PUT \
  --url https://api.smithery.ai/servers/{qualifiedName} \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "displayName": "My Server",
  "description": "A simple server"
}
'
import requests

url = "https://api.smithery.ai/servers/{qualifiedName}"

payload = {
    "displayName": "My Server",
    "description": "A simple server"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.text)
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.smithery.ai/servers/{qualifiedName}",
  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([
    'displayName' => 'My Server',
    'description' => 'A simple server'
  ]),
  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/servers/{qualifiedName}"

	payload := strings.NewReader("{\n \"displayName\": \"My Server\",\n \"description\": \"A simple server\"\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/servers/{qualifiedName}")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n \"displayName\": \"My Server\",\n \"description\": \"A simple server\"\n}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://api.smithery.ai/servers/{qualifiedName}")

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 \"displayName\": \"My Server\",\n \"description\": \"A simple server\"\n}"

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

201

400

401

403

404

{
  "namespace": "myorg",
  "server": "",
  "displayName": "My Server",
  "description": "A simple server",
  "createdAt": "2024-01-01T00:00:00.000Z"
}
{
  "error": "Server not found"
}
{
  "error": "Server not found"
}
{
  "error": "Server not found"
}
{
  "error": "Server not found"
}