创建凭据
curl --request POST \
--url https://api.moonshot.cn/v1/vaults/{id}/credentials \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"auth": {
"type": "static_bearer",
"mcp_server_url": "https://example.invalid/mcp",
"token": "sk-example"
}
}
'import requests
url = "https://api.moonshot.cn/v1/vaults/{id}/credentials"
payload = { "auth": {
"type": "static_bearer",
"mcp_server_url": "https://example.invalid/mcp",
"token": "sk-example"
} }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
auth: {
type: 'static_bearer',
mcp_server_url: 'https://example.invalid/mcp',
token: 'sk-example'
}
})
};
fetch('https://api.moonshot.cn/v1/vaults/{id}/credentials', 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.moonshot.cn/v1/vaults/{id}/credentials",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'auth' => [
'type' => 'static_bearer',
'mcp_server_url' => 'https://example.invalid/mcp',
'token' => 'sk-example'
]
]),
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.moonshot.cn/v1/vaults/{id}/credentials"
payload := strings.NewReader("{\n \"auth\": {\n \"type\": \"static_bearer\",\n \"mcp_server_url\": \"https://example.invalid/mcp\",\n \"token\": \"sk-example\"\n }\n}")
req, _ := http.NewRequest("POST", 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.post("https://api.moonshot.cn/v1/vaults/{id}/credentials")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"auth\": {\n \"type\": \"static_bearer\",\n \"mcp_server_url\": \"https://example.invalid/mcp\",\n \"token\": \"sk-example\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.moonshot.cn/v1/vaults/{id}/credentials")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"auth\": {\n \"type\": \"static_bearer\",\n \"mcp_server_url\": \"https://example.invalid/mcp\",\n \"token\": \"sk-example\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "vcrd_01h455vb4pex5vsknk084sn02q",
"vault_id": "vlt_01h455vb4pex5vsknk084sn02q",
"display_name": "MCP access",
"auth": {
"type": "static_bearer",
"mcp_server_url": "https://example.invalid/mcp"
},
"created_at": "2026-01-01T00:00:00.000Z",
"updated_at": "2026-01-01T00:00:00.000Z"
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}在凭据库(Vault)中存储一条凭据。秘密值为只写:仅在请求中接受,静态加密存储,且在任何响应中都不返回。
- 凭据的唯一键——
mcp_oauth/static_bearer为规范化后的mcp_server_url,environment_variable为secret_name——不得与凭据库(Vault)中的另一条活跃凭据冲突(409conflict_error)。 - 一个凭据库(Vault)最多持有 20 条活跃凭据(400
failed_precondition_error)。已归档的凭据库(Vault)拒绝新凭据。
POST
/
v1
/
vaults
/
{id}
/
credentials
创建凭据
curl --request POST \
--url https://api.moonshot.cn/v1/vaults/{id}/credentials \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"auth": {
"type": "static_bearer",
"mcp_server_url": "https://example.invalid/mcp",
"token": "sk-example"
}
}
'import requests
url = "https://api.moonshot.cn/v1/vaults/{id}/credentials"
payload = { "auth": {
"type": "static_bearer",
"mcp_server_url": "https://example.invalid/mcp",
"token": "sk-example"
} }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
auth: {
type: 'static_bearer',
mcp_server_url: 'https://example.invalid/mcp',
token: 'sk-example'
}
})
};
fetch('https://api.moonshot.cn/v1/vaults/{id}/credentials', 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.moonshot.cn/v1/vaults/{id}/credentials",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'auth' => [
'type' => 'static_bearer',
'mcp_server_url' => 'https://example.invalid/mcp',
'token' => 'sk-example'
]
]),
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.moonshot.cn/v1/vaults/{id}/credentials"
payload := strings.NewReader("{\n \"auth\": {\n \"type\": \"static_bearer\",\n \"mcp_server_url\": \"https://example.invalid/mcp\",\n \"token\": \"sk-example\"\n }\n}")
req, _ := http.NewRequest("POST", 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.post("https://api.moonshot.cn/v1/vaults/{id}/credentials")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"auth\": {\n \"type\": \"static_bearer\",\n \"mcp_server_url\": \"https://example.invalid/mcp\",\n \"token\": \"sk-example\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.moonshot.cn/v1/vaults/{id}/credentials")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"auth\": {\n \"type\": \"static_bearer\",\n \"mcp_server_url\": \"https://example.invalid/mcp\",\n \"token\": \"sk-example\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "vcrd_01h455vb4pex5vsknk084sn02q",
"vault_id": "vlt_01h455vb4pex5vsknk084sn02q",
"display_name": "MCP access",
"auth": {
"type": "static_bearer",
"mcp_server_url": "https://example.invalid/mcp"
},
"created_at": "2026-01-01T00:00:00.000Z",
"updated_at": "2026-01-01T00:00:00.000Z"
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}路径参数
凭据库(Vault)ID。
Pattern:
^vlt_[0-9a-hjkmnp-tv-z]{26}$请求体
application/json
向凭据库(Vault)添加一条凭据的请求体。
每条凭据都有一个唯一键——mcp_oauth/static_bearer 为规范化后的 mcp_server_url,environment_variable 为 secret_name——在该凭据库(Vault)的活跃凭据中唯一。
响应
已创建的凭据,秘密值不返回。
凭据库(Vault)中存储的一条凭据。唯一键——mcp_oauth/static_bearer 为规范化后的 mcp_server_url,environment_variable 为 secret_name——在同一凭据库的活跃凭据中不可重复。
凭据 ID。
Pattern:
^vcrd_[0-9a-hjkmnp-tv-z]{26}$所属凭据库(Vault)的 ID。
Pattern:
^vlt_[0-9a-hjkmnp-tv-z]{26}$人类可读的凭据名称。
MCP 服务器的 OAuth 2.0 凭据。
- MCP OAuth 凭据
- 静态 Bearer 凭据
- 环境变量凭据
Show child attributes
Show child attributes
创建时间戳。
最后更新时间戳。
归档时间戳。活跃期间不含此字段。
此页面对您有帮助吗?