Skip to main content
Glama
heizaheiza

Charles MCP Server

by heizaheiza

query_recorded_traffic

Search and filter previously captured network traffic recordings to analyze HTTP requests and responses by host, method, or content patterns.

Instructions

Query the latest saved recording. This tool never reads the live Charles session.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
host_containsNo按 host 子串过滤(包含匹配)。例如:api.example.com
http_methodNoHTTP 方法过滤。仅允许标准 HTTP 方法。必须是方法名,不是正则表达式,不是路径。
keyword_regexNo用于搜索请求/响应内容的 Python 正则表达式。建议使用短表达式,避免灾难性回溯。
keep_requestNo
keep_responseNo

Implementation Reference

  • The implementation of the `query_recorded_traffic` MCP tool, which queries the latest saved recording.
    async def query_recorded_traffic(
        ctx: ToolContext,
        host_contains: HostContains = None,
        http_method: HttpMethodFilter = None,
        keyword_regex: KeywordRegex = None,
        keep_request: bool = True,
        keep_response: bool = True,
    ) -> RecordedTrafficQueryResult:
        """Query the latest saved recording. This tool never reads the live Charles session."""
        deps = get_tool_dependencies(ctx)
        host_contains_normalized = normalize_text_filter(host_contains)
        method_normalized, method_error = normalize_http_method(http_method)
        if method_error:
            raise ValueError(guidance_error_message(method_error))
    
        if keyword_regex:
            valid, error_msg = deps.history_service.validate_keyword_regex(keyword_regex)
            if not valid:
                raise ValueError(
                    guidance_error_message(
                        build_tool_guidance_error(
                            parameter="keyword_regex",
                            received=keyword_regex,
                            reason=f"invalid regex: {error_msg}",
                            valid_input="Provide a valid Python regular expression.",
                            retry_example='query_recorded_traffic(keyword_regex="token|session")',
                        )
                    )
                )
    
        return await deps.history_service.query_latest_result(
            host_contains=host_contains_normalized,
            method_normalized=method_normalized,
            keyword_regex=keyword_regex,
            keep_request=keep_request,
            keep_response=keep_response,
        )

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