Skip to main content
Glama
qiniu

Qiniu MCP Server

Official
by qiniu

cdn_prefetch_urls

Submit resource URLs to trigger proactive retrieval and caching by the CDN. Enhances accessibility by storing specified resources on cache nodes in advance.

Instructions

Newly added resources are proactively retrieved by the CDN and stored on its cache nodes in advance. Users simply submit the resource URLs, and the CDN automatically triggers the prefetch process.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlsYesList of individual URLs to prefetch (max 60 items). Must be full URLs with protocol, e.g. 'http://example.com/file.zip'

Implementation Reference

  • The decorated handler function for the 'cdn_prefetch_urls' MCP tool, including input schema and logic to call CDNService.prefetch_urls and format the response as TextContent.
    @tools.tool_meta( types.Tool( name="cdn_prefetch_urls", description="Newly added resources are proactively retrieved by the CDN and stored on its cache nodes in advance. Users simply submit the resource URLs, and the CDN automatically triggers the prefetch process.", inputSchema={ "type": "object", "additionalProperties": False, "properties": { "urls": { "type": "array", "description": "List of individual URLs to prefetch (max 60 items). Must be full URLs with protocol, e.g. 'http://example.com/file.zip'", "items": { "type": "string", "format": "uri", "pattern": "^https?://", "examples": [ "https://cdn.example.com/images/photo.jpg", "http://static.example.com/downloads/app.exe", ], }, "maxItems": 60, "minItems": 1, } }, "required": ["urls"], }, ) ) def prefetch_urls(self, **kwargs) -> list[types.TextContent]: ret = self._cdn.prefetch_urls(**kwargs) rets = _build_base_list(ret.code, ret.error, ret.requestId) if ret.invalidUrls: rets.append(f"Invalid URLs: {ret.invalidUrls}") if ret.code // 100 == 2: if ret.quotaDay is not None: rets.append(f"Today's prefetch quota: {ret.quotaDay}") if ret.surplusDay is not None: rets.append(f"Today's remaining quota: {ret.surplusDay}") return [ types.TextContent( type="text", text="\n".join(rets), ) ]
  • Registers the CDN tool handlers (including cdn_prefetch_urls) with the MCP tools system using auto_register_tools.
    def register_tools(cdn: CDNService): tool_impl = _ToolImpl(cdn) tools.auto_register_tools( [ tool_impl.refresh, tool_impl.prefetch_urls, ] )
  • Entry point that initializes CDNService and calls register_tools to register the CDN MCP tools.
    def load(cfg: config.Config): cdn = CDNService(cfg) register_tools(cdn)
  • Underlying implementation of URL prefetching using Qiniu's CdnManager, called by the tool handler.
    def prefetch_urls(self, urls: List[str] = []) -> PrefetchUrlsResult: if not urls: raise ValueError("urls is empty") info, resp = self._cdn_manager.prefetch_urls(urls) _raise_if_resp_error(resp) return PrefetchUrlsResult.model_validate(info)
  • Pydantic model for the result of prefetch_urls operation, used for validation and response handling.
    @dataclass class PrefetchUrlsResult(BaseModel): code: Optional[int] = None error: Optional[str] = None requestId: Optional[str] = None invalidUrls: Optional[List[str]] = None quotaDay: Optional[int] = None surplusDay: Optional[int] = None

Other Tools

Related 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/qiniu/qiniu-mcp-server'

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