sm_create_secret
Create a new secret in IBM Cloud Secrets Manager. Specify type and payload to store sensitive data securely.
Instructions
Create a new secret
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| instance_id | Yes | ||
| name | Yes | ||
| secret_type | Yes | ||
| payload | Yes | Secret value or JSON of fields depending on type | |
| secret_group_id | No | ||
| region | No |
Implementation Reference
- src/tools/security/index.ts:23-34 (handler)The tool handler for sm_create_secret. It builds the request body based on secret_type (arbitrary, kv, or other JSON-based types) and posts to the Secrets Manager API endpoint.
server.tool("sm_create_secret", "Create a new secret", { instance_id: z.string(), name: z.string(), secret_type: z.enum(["arbitrary","username_password","iam_credentials","kv","public_cert","private_cert","service_credentials"]), payload: z.string().describe("Secret value or JSON of fields depending on type"), secret_group_id: z.string().optional(), region: z.string().optional(), }, async (p) => safeTool(async () => { w(); const body: Record<string,unknown> = {name:p.name, secret_type:p.secret_type, secret_group_id:p.secret_group_id}; if(p.secret_type==="arbitrary") body.payload=p.payload; else if(p.secret_type==="kv") body.data=JSON.parse(p.payload); else Object.assign(body, JSON.parse(p.payload)); return client.post(`${sm(p.instance_id,p.region)}/secrets`, body); })); - src/tools/security/index.ts:23-27 (schema)Schema definition for sm_create_secret: input parameters including instance_id, name, secret_type (enum), payload, optional secret_group_id and region.
server.tool("sm_create_secret", "Create a new secret", { instance_id: z.string(), name: z.string(), secret_type: z.enum(["arbitrary","username_password","iam_credentials","kv","public_cert","private_cert","service_credentials"]), payload: z.string().describe("Secret value or JSON of fields depending on type"), secret_group_id: z.string().optional(), region: z.string().optional(), - src/tools/security/index.ts:23-34 (registration)The tool is registered via server.tool('sm_create_secret', ...) inside the registerSecurityTools function.
server.tool("sm_create_secret", "Create a new secret", { instance_id: z.string(), name: z.string(), secret_type: z.enum(["arbitrary","username_password","iam_credentials","kv","public_cert","private_cert","service_credentials"]), payload: z.string().describe("Secret value or JSON of fields depending on type"), secret_group_id: z.string().optional(), region: z.string().optional(), }, async (p) => safeTool(async () => { w(); const body: Record<string,unknown> = {name:p.name, secret_type:p.secret_type, secret_group_id:p.secret_group_id}; if(p.secret_type==="arbitrary") body.payload=p.payload; else if(p.secret_type==="kv") body.data=JSON.parse(p.payload); else Object.assign(body, JSON.parse(p.payload)); return client.post(`${sm(p.instance_id,p.region)}/secrets`, body); })); - src/server.ts:74-75 (registration)The registerSecurityTools function is called from createServer() in server.ts, registering all security-related tools including sm_create_secret.
registerSecurityTools(server, client, config); console.error(` ✓ Security (12 tools)`); - src/tools/security/index.ts:61-64 (helper)The sm helper function builds the Secrets Manager API endpoint URL using IBM_ENDPOINTS.SECRETS_MANAGER with the instance ID and region.
client.request(`${kp(p.region)}/keys`, {headers:{"Bluemix-Instance":p.instance_id}, queryParams:{limit:p.limit||200}}) )); server.tool("kp_create_key", "Create a new encryption key", {