Skip to main content
Glama
mothlike

MCP Graylog Server

by mothlike

search_stream_logs

Search and filter log messages within specific Graylog streams using Elasticsearch query syntax, time ranges, and field selections to quickly find relevant log data.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
stream_idYes
searchYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The `search_stream_logs` handler function. It takes a stream_id and a MessageSearchInput, validates the stream_id, creates a copy of the search with the stream_id set, and delegates to graylog.search_messages().
    def search_stream_logs(
        self, stream_id: str, search: MessageSearchInput
    ) -> dict[str, Any]:
        clean_stream_id = stream_id.strip()
        if not clean_stream_id:
            raise ValueError("stream_id must not be empty")
    
        stream_search = search.model_copy(update={"streams": [clean_stream_id]})
        return self.graylog.search_messages(stream_search)
  • The `MessageSearchInput` Pydantic model used as input schema for search_stream_logs. Defines fields: query, timerange, streams, fields, limit, offset.
    class MessageSearchInput(BaseModel):
        query: str = Field("*", min_length=1)
        timerange: TimeRange = Field(
            default_factory=lambda: RelativeTimeRange.model_validate({})
        )
        streams: list[str] = Field(default_factory=list)
        fields: list[str] = Field(
            default_factory=lambda: ["timestamp", "source", "level", "message"]
        )
        limit: int = Field(50, ge=1, le=1000)
        offset: int = Field(0, ge=0)
    
        @field_validator("query")
        @classmethod
        def strip_query(cls, value: str) -> str:
            stripped = value.strip()
            if not stripped:
                raise ValueError("query must not be empty")
            return stripped
    
        def to_graylog_payload(self) -> dict[str, object]:
            payload: dict[str, object] = {
                "query": self.query,
                "timerange": self.timerange.to_graylog(),
                "size": self.limit,
                "from": self.offset,
            }
            if self.streams:
                payload["streams"] = list(self.streams)
            if self.fields:
                payload["fields"] = list(self.fields)
            return payload
  • Registration of `search_stream_logs` as an MCP tool via `mcp.tool()(handlers.search_stream_logs)`.
    mcp.tool()(handlers.search_stream_logs)
  • The `search_messages` method on GraylogClient that the handler ultimately delegates to for executing the search.
    def search_messages(self, search: MessageSearchInput) -> dict[str, Any]:
  • Test verifying that search_stream_logs correctly adds a stream without mutating the original search input.
    def test_search_stream_logs_adds_stream_without_mutating_original_search() -> None:
        fake = FakeGraylogClient()
        handlers = create_tool_handlers(fake)
        search = MessageSearchInput(
            query="source:api",
            streams=["original"],
            limit=50,
            offset=0,
        )
    
        result = handlers.search_stream_logs("stream-1", search)
    
        assert result["total_results"] == 1
        assert search.streams == ["original"]
        assert fake.search_input is not search
        assert fake.search_input is not None
        assert fake.search_input.streams == ["stream-1"]
        assert fake.search_input.query == "source:api"
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Tool has no description.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness1/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Tool has no description.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Tool has no description.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Tool has no description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose1/5

Does the description clearly state what the tool does and how it differs from similar tools?

Tool has no description.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Tool has no description.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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/mothlike/mcp-graylog'

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