Skip to main content
Glama
heizaheiza

Charles MCP Server

by heizaheiza

throttling

Simulate network conditions by applying preset bandwidth limits like 3G, 4G, or 5G to test application performance under different connection speeds.

Instructions

Set a network throttling preset in Charles.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
presetYes弱网预设名称。仅允许固定值:3G/4G/5G/fibre/100mbps/56k/256k/deactivate/off/on/start。

Implementation Reference

  • The `throttling` tool implementation that handles the input, validates the preset, and calls the Charles client.
    async def throttling(ctx: ToolContext, preset: ThrottlingPreset) -> str:
        """Set a network throttling preset in Charles."""
        logger.info("Tool called: throttling(preset=%s)", preset)
        deps = get_tool_dependencies(ctx)
    
        preset_clean = preset.strip()
        if not preset_clean:
            return (
                "Error: parameter `preset` cannot be empty. "
                "Use one of the supported presets, for example: 3G / 4G / 5G / off / deactivate."
            )
    
        preset_lower = preset_clean.lower()
        supported = {value.lower() for value in THROTTLING_PRESET_CHOICES}
        if preset_lower not in supported:
            return (
                "Error: parameter `preset` is invalid. "
                f"Supported values: {', '.join(THROTTLING_PRESET_CHOICES)}. "
                'Retry with something like throttling("3G") or throttling("off").'
            )
    
        normalized_preset = "3G" if preset_lower in ("start", "on") else preset_clean
    
        try:
            async with deps.client_factory(deps.config) as client:
                success, message = await client.set_throttling(normalized_preset)
                return f"{'Success' if success else 'Error'}: {message}"
        except CharlesClientError as exc:
            logger.error("Throttling error: %s", exc)
            return f"Error: {exc}"
  • The MCP tool decorator registration for `throttling`.
    @mcp.tool()
    async def throttling(ctx: ToolContext, preset: ThrottlingPreset) -> str:
  • The `ThrottlingPreset` type definition used for input validation in the throttling tool.
    ThrottlingPreset = Annotated[
        str,
        Field(
            description=(
                "弱网预设名称。"
                "仅允许固定值:3G/4G/5G/fibre/100mbps/56k/256k/deactivate/off/on/start。"
            ),
            json_schema_extra={"enum": list(THROTTLING_PRESET_CHOICES)},
        ),
    ]

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/heizaheiza/Charles-mcp'

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