Skip to main content
Glama
omgwtfwow

MCP Server for Crawl4AI

by omgwtfwow

extract_with_llm

Extract specific information from webpages using AI by asking questions about content. Crawls fresh content each time to answer queries about topics, prices, summaries, or contact details.

Instructions

[STATELESS] Ask questions about webpage content using AI. Returns natural language answers. Crawls fresh each time. For dynamic content or sessions, use crawl with session_id first.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesThe URL to extract data from
queryYesYour question about the webpage content. Examples: "What is the main topic?", "List all product prices", "Summarize the key points", "What contact information is available?"

Implementation Reference

  • Handler function that executes the tool logic: calls the service, extracts the answer, and formats the MCP response with content type 'text'.
    async extractWithLLM(options: { url: string; query: string }) {
      try {
        const result = await this.service.extractWithLLM(options);
    
        return {
          content: [
            {
              type: 'text',
              text: result.answer,
            },
          ],
        };
      } catch (error) {
        throw this.formatError(error, 'extract with LLM');
      }
    }
  • Core service method that performs the actual HTTP request to the Crawl4AI backend's /llm endpoint with URL and query parameters, handles specific errors like timeout and auth.
    async extractWithLLM(options: LLMEndpointOptions): Promise<LLMEndpointResponse> {
      // Validate URL
      if (!validateURL(options.url)) {
        throw new Error('Invalid URL format');
      }
    
      try {
        const encodedUrl = encodeURIComponent(options.url);
        const encodedQuery = encodeURIComponent(options.query);
        const response = await this.axiosClient.get(`/llm/${encodedUrl}?q=${encodedQuery}`);
        return response.data;
      } catch (error) {
        // Special handling for LLM-specific errors
        if (axios.isAxiosError(error)) {
          const axiosError = error as AxiosError;
          if (axiosError.code === 'ECONNABORTED' || axiosError.response?.status === 504) {
            throw new Error('LLM extraction timed out. Try a simpler query or different URL.');
          }
          if (axiosError.response?.status === 401) {
            throw new Error(
              'LLM extraction failed: No LLM provider configured on server. Please ensure the server has an API key set.',
            );
          }
        }
        return handleAxiosError(error);
      }
    }
  • Zod schema for input validation: requires url (valid URL) and query (string). Uses createStatelessSchema helper.
    export const ExtractWithLlmSchema = createStatelessSchema(
      z.object({
        url: z.string().url(),
        query: z.string(),
      }),
      'extract_with_llm',
    );
  • src/server.ts:890-896 (registration)
    Tool registration in the CallToolRequestSchema handler switch statement: uses ExtractWithLlmSchema for validation and delegates to contentHandlers.extractWithLLM.
    case 'extract_with_llm':
      return await this.validateAndExecute(
        'extract_with_llm',
        args,
        ExtractWithLlmSchema,
        async (validatedArgs) => this.contentHandlers.extractWithLLM(validatedArgs),
      );
Behavior4/5

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

With no annotations provided, the description carries full burden and discloses key behavioral traits: stateless operation (via [STATELESS] tag), fresh crawling each time, natural language return format, and limitations with dynamic/session content. It doesn't mention rate limits, authentication needs, or error handling, but covers core operational behavior well.

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

Conciseness5/5

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

Perfectly front-loaded with the core purpose first, followed by key behavioral notes and usage guidance. Every sentence earns its place with zero wasted words, making it highly scannable and efficient.

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

Completeness4/5

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

For a 2-parameter tool with no annotations and no output schema, the description provides good coverage of purpose, behavior, and usage context. It could be more complete by describing the return format in more detail (beyond 'natural language answers') or error scenarios, but it adequately supports agent decision-making given the tool's complexity.

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

Parameters3/5

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

Schema description coverage is 100%, so the schema already documents both parameters thoroughly. The description adds marginal value by implying the relationship between URL and query (asking questions 'about webpage content') but doesn't provide additional syntax or format details beyond what the schema provides.

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

Purpose5/5

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

The description clearly states the tool's purpose with specific verbs ('Ask questions about webpage content using AI') and resources ('webpage content'), distinguishing it from siblings by focusing on AI-powered Q&A rather than raw crawling, screenshot capture, or link extraction.

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

Usage Guidelines5/5

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

Explicitly provides when-to-use guidance ('Crawls fresh each time') and when-not-to-use alternatives ('For dynamic content or sessions, use crawl with session_id first'), naming a specific sibling tool (crawl) for comparison.

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/omgwtfwow/mcp-crawl4ai-ts'

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