cdn_prefetch_urls
Prefetch URLs on Qiniu CDN to proactively cache resources and reduce latency for users by submitting up to 60 URLs for automatic retrieval and storage on cache nodes.
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
| Name | Required | Description | Default |
|---|---|---|---|
| urls | Yes | List of individual URLs to prefetch (max 60 items). Must be full URLs with protocol, e.g. 'http://example.com/file.zip' |
Implementation Reference
- src/mcp_server/core/cdn/tools.py:58-75 (handler)MCP tool handler for 'cdn_prefetch_urls'. Parses kwargs, calls CDNService.prefetch_urls, formats status/error/quota info into TextContent response.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), ) ]
- Input schema definition for the cdn_prefetch_urls tool, specifying urls as array of URIs (1-60 items).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"], }, )
- src/mcp_server/core/cdn/tools.py:145-150 (registration)Registers the prefetch_urls tool handler using auto_register_tools in the register_tools function.tools.auto_register_tools( [ tool_impl.refresh, tool_impl.prefetch_urls, ] )
- src/mcp_server/core/cdn/cdn.py:50-55 (handler)Core implementation of prefetch_urls in CDNService, invoking qiniu CdnManager.prefetch_urls and validating response.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)
- src/mcp_server/core/cdn/cdn.py:16-22 (schema)Pydantic BaseModel schema for the result of prefetch_urls operation, including code, error, quotas, etc.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