cos_put_object
Uploads a text object to an IBM Cloud Object Storage bucket, given the bucket name, object key, and content. Optionally specify content type.
Instructions
Upload an object to a bucket
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bucket_name | Yes | ||
| object_key | Yes | ||
| content | Yes | Object content (text) | |
| content_type | No | MIME type | |
| region | No |
Implementation Reference
- src/tools/cos/index.ts:60-69 (handler)Handler for the cos_put_object tool. Makes a PUT request to the COS S3 endpoint with the object content as the body. Calls w() (assertWriteAllowed) to enforce read-only mode if configured.
server.tool("cos_put_object", "Upload an object to a bucket", { bucket_name: z.string(), object_key: z.string(), content: z.string().describe("Object content (text)"), content_type: z.string().optional().describe("MIME type"), region: z.string().optional(), }, async (p) => safeTool(async () => { w(); return client.request(`${s3(p.region||r)}/${p.bucket_name}/${encodeURIComponent(p.object_key)}`, { method:"PUT", headers:{"Content-Type":p.content_type||"text/plain"}, body:p.content, }); })); - src/tools/cos/index.ts:61-62 (schema)Input schema for cos_put_object: bucket_name (required), object_key (required), content (required text), content_type (optional MIME type), region (optional, defaults to server config region).
bucket_name: z.string(), object_key: z.string(), content: z.string().describe("Object content (text)"), content_type: z.string().optional().describe("MIME type"), region: z.string().optional(), - src/tools/cos/index.ts:60-69 (registration)Registration of the cos_put_object tool on the MCP server via server.tool() call, within the registerCOSTools function.
server.tool("cos_put_object", "Upload an object to a bucket", { bucket_name: z.string(), object_key: z.string(), content: z.string().describe("Object content (text)"), content_type: z.string().optional().describe("MIME type"), region: z.string().optional(), }, async (p) => safeTool(async () => { w(); return client.request(`${s3(p.region||r)}/${p.bucket_name}/${encodeURIComponent(p.object_key)}`, { method:"PUT", headers:{"Content-Type":p.content_type||"text/plain"}, body:p.content, }); })); - src/server.ts:59-59 (registration)Top-level registration call that wires up all COS tools including cos_put_object during server initialization.
registerCOSTools(server, client, config); - src/lib/utils.ts:14-18 (helper)Helper function used by the handler to enforce read-only mode. Calls w() which invokes assertWriteAllowed(config.allowWrite).
export function assertWriteAllowed(allowWrite: boolean): void { if (!allowWrite) { throw new WriteNotAllowedError(); } }