Skip to main content
Glama

putObjectSourceUrl

Downloads files from a URL and uploads them to cloud storage buckets for automated file transfer and management.

Instructions

通过 url下载文件并将文件上传到存储桶

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sourceUrlYes可下载的文件 url
fileNameNo文件名 (存在存储桶里的名称)
targetDirNo目标目录 (存在存储桶的哪个目录)

Implementation Reference

  • Core handler implementation: downloads file from sourceUrl using axios stream, generates filename if needed, builds COS path, and uploads via cos.putObject using PassThrough stream.
    async uploadFileSourceUrl(params: UploadFileParams) {
      // 验证并解析参数
      const validParams = UploadFileParamsSchema.parse(params);
      const { targetDir = '', fileName, sourceUrl } = validParams;
      try {
        const response = await axios({
          method: 'get',
          url: sourceUrl,
          responseType: 'stream'
        });
        const actualFileName = fileName ? fileName : generateOutPutFileId('');
        const cosPath = this.buildCosPath(actualFileName, targetDir);
        const req = response.data;
        const passThrough = new PassThrough();
        const result = await this.cos.putObject({
          Bucket: this.bucket,
          Region:this.region,
          Key: cosPath,
          Body: req.pipe(passThrough),
        });
        return {
          isSuccess: true,
          message: '上传成功',
          data: result,
        };
      } catch (error) {
        return {
          isSuccess: false,
          message: '上传失败',
          data: error,
        };
      }
    }
  • src/server.ts:221-248 (registration)
    MCP tool registration for 'putObjectSourceUrl', defines input schema with Zod and inline handler that delegates to CosService.uploadFileSourceUrl
    server.tool(
      'putObjectSourceUrl',
      '通过 url下载文件并将文件上传到存储桶',
      {
        sourceUrl: z.string().describe('可下载的文件 url'),
        fileName: z.string().optional().describe('文件名 (存在存储桶里的名称)'),
        targetDir: z
          .string()
          .optional()
          .describe('目标目录 (存在存储桶的哪个目录)'),
      },
      async ({ sourceUrl, fileName, targetDir}) => {
        const res = await COSInstance.uploadFileSourceUrl({
          targetDir,
          fileName,
          sourceUrl,
        });
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(res.data, null, 2),
            },
          ],
          isError: !res.isSuccess,
        };
      },
    );
  • Zod schema used in the handler for validating upload parameters including sourceUrl.
    export const UploadFileParamsSchema = z.object({
      filePath: z.string().optional(),
      targetDir: z.string().optional(),
      fileName: z.string().optional(),
      sourceUrl: z.string().optional()
    });
    export type UploadFileParams = z.infer<typeof UploadFileParamsSchema>;
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool downloads and uploads a file, implying a write operation, but lacks details on permissions, error handling, rate limits, or what happens if the URL is invalid. This is a significant gap for a mutation tool with zero annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core functionality. There is no wasted text, and it directly conveys the tool's purpose without redundancy or unnecessary details.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (a mutation operation with 3 parameters), lack of annotations, and no output schema, the description is incomplete. It does not explain return values, error conditions, or behavioral traits like whether the upload overwrites existing files, making it inadequate for safe and effective use by an AI agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all three parameters (sourceUrl, fileName, targetDir) with descriptions. The description does not add any meaning beyond the schema, such as URL format examples or directory path conventions, but the baseline is 3 when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: download a file from a URL and upload it to a storage bucket. It uses specific verbs ('download', 'upload') and identifies the resource ('file', 'storage bucket'). However, it does not explicitly differentiate from sibling tools like putObject, putBase64, or putBuffer, which may handle similar uploads with different input types.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It does not mention sibling tools like putObject (which might handle direct uploads) or putBase64/putBuffer (for other data formats), nor does it specify prerequisites or exclusions, such as URL accessibility or file size limits.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/xiaomizhoubaobei/MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server