Skip to main content
Glama

mock_search

Retrieve financial information from the internet by searching with specific keywords. Supports financial research and analysis workflows.

Instructions

Use search keywords to retrieve relevant information from the internet. If you have multiple keywords, please call this tool separately for each one.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYessearch keyword

Implementation Reference

  • The async_execute method implements the handler logic for the mock_search tool, using an LLM to generate mock search results in JSON format based on the query.
    async def async_execute(self): """Generate mock search results using an LLM. The method builds a small conversation where the system message instructs the model to return JSON-formatted search results, and the user message contains the formatted query. The JSON structure is then extracted and pretty-printed. """ query: str = self.input_dict["query"] if not query: answer = "query is empty, no results found." logger.warning(answer) self.set_output(answer) return messages = [ Message( role=Role.SYSTEM, content="You are a helpful assistant that generates realistic search results in JSON format.", ), Message( role=Role.USER, content=self.prompt_format( "mock_search_op_prompt", query=query, num_results=random.randint(0, 5), ), ), ] logger.info(f"messages={messages}") def callback_fn(message: Message): return extract_content(message.content, "json") search_results: str = await self.llm.achat(messages=messages, callback_fn=callback_fn) self.set_output(json.dumps(search_results, ensure_ascii=False, indent=2))
  • The build_tool_call method defines the input schema and description for the mock_search tool.
    def build_tool_call(self) -> ToolCall: """Build the tool call schema describing the mock search tool. Returns: ToolCall: Definition containing description and input schema for the ``query`` parameter. """ return ToolCall( **{ "description": self.get_prompt("tool_description"), "input_schema": { "query": { "type": "string", "description": "search keyword", "required": True, }, }, }, )
  • The MockSearchOp class is registered via @C.register_op(), which registers it as the mock_search tool in the MCP framework.
    @C.register_op() class MockSearchOp(BaseAsyncToolOp): """Asynchronous mock search tool that generates LLM-based results."""

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/FlowLLM-AI/finance-mcp'

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