Skip to main content
Glama
Dasistaiden

whed-tools

by Dasistaiden

extract_first

Extract the first element matching a CSS selector from a webpage to retrieve single values like page titles, headings, or metadata.

Instructions

Extract the first matching element from a webpage.
Useful for getting single values like page title, main heading, etc.

Args:
    url: The webpage to scrape
    css_selector: CSS selector for the element (e.g., "h1", "title", "meta[name='description']")
    attribute: What to extract - "text" for content, or attribute name like "href", "content", "src"
    javascript: Set to True for JavaScript-rendered sites
    save_path: Optional file path to save the result as JSON (e.g. "C:/Users/me/Desktop/result.json").
               If a directory is given, a timestamped filename is generated automatically.

Returns:
    Dictionary with the extracted value

Example:
    extract_first(url="https://example.com", css_selector="title", attribute="text")

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYes
attributeNotext
save_pathNo
javascriptNo
css_selectorYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.2.0

TDQS

A3.6/5.0
Behavior3/5

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

With no annotations, the description carries the full behavioral burden, and it does add real context: the javascript flag for rendered sites and the save_path directory-to-timestamped-filename behavior. However, it is silent on critical scraper behavior such as what happens when no element matches (error vs. null), rate limiting, or network/permission requirements.

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

Conciseness4/5

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

Purpose is front-loaded in the first sentence, followed by a tightly organized Args/Returns/Example block; each section carries distinct information. The docstring formatting is slightly verbose for a tool description, but nothing is wasted.

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?

An output schema exists, so the description need not detail return values, yet it still gives a concise 'Dictionary with the extracted value' summary. For a 5-parameter, unannotated scraping tool the main remaining gap is failure/miss behavior when the selector matches nothing.

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

Parameters4/5

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

Schema description coverage is 0% and there are 5 parameters, so the description must compensate, and it largely does: every parameter is explained, including valid values for attribute ('text' vs. an attribute name like href/content/src) and CSS selector examples. It omits the default for javascript and does not elaborate on save_path's JSON format beyond one example.

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

Purpose4/5

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

The description states a specific verb and resource ('Extract the first matching element from a webpage') and clarifies the single-value use case, which distinguishes it implicitly from bulk siblings like extract_data or batch_scrape. It never names a sibling explicitly, so an agent must infer the boundary from the phrase 'first matching element'.

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

Usage Guidelines3/5

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

The line 'Useful for getting single values like page title, main heading, etc.' implies when the tool is appropriate, but there is no explicit guidance about when not to use it or how it differs from extract_data or scrape_url. Usage is suggested rather than specified.

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