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
| 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:30-75 (handler)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), ) ]
- src/mcp_server/core/cdn/tools.py:143-150 (registration)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, ] )
- src/mcp_server/core/cdn/__init__.py:6-8 (registration)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)
- src/mcp_server/core/cdn/cdn.py:50-55 (helper)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)
- src/mcp_server/core/cdn/cdn.py:15-23 (helper)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