Skip to main content
Glama
datagouv

datagouv-mcp

by datagouv

get_resource_info

Retrieve metadata for data files to determine optimal query method. Check format, size, and Tabular API availability to choose between direct querying or downloading.

Instructions

Get detailed information about a specific resource (file).

Returns comprehensive metadata including format, size, MIME type, URL, and associated dataset information. Also checks if the resource is available via the Tabular API (data.gouv.fr's API for parsing tabular files without downloading them).

Use this tool to determine which data querying tool to use:

  • If available via Tabular API: use query_resource_data (faster, no download needed)

  • If not available or too large: use download_and_parse_resource

Typical workflow:

  1. Use list_dataset_resources to find resources in a dataset

  2. Use get_resource_info to check resource details and Tabular API availability

  3. Use query_resource_data or download_and_parse_resource based on availability

Args: resource_id: The ID of the resource to get information about (obtained from list_dataset_resources)

Returns: Formatted text with detailed resource information, including Tabular API availability status

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
resource_idYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main handler function that executes the tool logic: fetches resource details from data.gouv.fr API, formats metadata (title, size, format, etc.), retrieves dataset info, and checks availability via Tabular API.
    async def get_resource_info(resource_id: str) -> str:
        """
        Get detailed information about a specific resource (file).
    
        Returns comprehensive metadata including format, size, MIME type, URL,
        and associated dataset information. Also checks if the resource is available
        via the Tabular API (data.gouv.fr's API for parsing tabular files without
        downloading them).
    
        Use this tool to determine which data querying tool to use:
        - If available via Tabular API: use query_resource_data (faster, no download needed)
        - If not available or too large: use download_and_parse_resource
    
        Typical workflow:
        1. Use list_dataset_resources to find resources in a dataset
        2. Use get_resource_info to check resource details and Tabular API availability
        3. Use query_resource_data or download_and_parse_resource based on availability
    
        Args:
            resource_id: The ID of the resource to get information about (obtained from list_dataset_resources)
    
        Returns:
            Formatted text with detailed resource information, including Tabular API availability status
        """
        try:
            # Get full resource data from API v2
            resource_data = await datagouv_api_client.get_resource_details(resource_id)
            resource = resource_data.get("resource", {})
            if not resource.get("id"):
                return f"Error: Resource with ID '{resource_id}' not found."
    
            resource_title = resource.get("title") or resource.get("name") or "Unknown"
    
            content_parts = [
                f"Resource Information: {resource_title}",
                "",
                f"Resource ID: {resource_id}",
            ]
    
            if resource.get("format"):
                content_parts.append(f"Format: {resource.get('format')}")
    
            if resource.get("filesize"):
                size = resource.get("filesize")
                if isinstance(size, int):
                    # Format size in human-readable format
                    if size < 1024:
                        size_str = f"{size} B"
                    elif size < 1024 * 1024:
                        size_str = f"{size / 1024:.1f} KB"
                    elif size < 1024 * 1024 * 1024:
                        size_str = f"{size / (1024 * 1024):.1f} MB"
                    else:
                        size_str = f"{size / (1024 * 1024 * 1024):.1f} GB"
                    content_parts.append(f"Size: {size_str}")
    
            if resource.get("mime"):
                content_parts.append(f"MIME type: {resource.get('mime')}")
    
            if resource.get("type"):
                content_parts.append(f"Type: {resource.get('type')}")
    
            if resource.get("url"):
                content_parts.append("")
                content_parts.append(f"URL: {resource.get('url')}")
    
            if resource.get("description"):
                content_parts.append("")
                content_parts.append(f"Description: {resource.get('description')}")
    
            # Dataset information
            dataset_id = resource_data.get("dataset_id")
            if dataset_id:
                content_parts.append("")
                content_parts.append(f"Dataset ID: {dataset_id}")
                try:
                    dataset_meta = await datagouv_api_client.get_dataset_metadata(
                        str(dataset_id)
                    )
                    if dataset_meta.get("title"):
                        content_parts.append(f"Dataset: {dataset_meta.get('title')}")
                except Exception:  # noqa: BLE001
                    pass
    
            # Check if resource is available via Tabular API
            content_parts.append("")
            try:
                # Try to get profile to check if it's tabular
                profile_url = f"{env_config.get_base_url('tabular_api')}resources/{resource_id}/profile/"
                async with httpx.AsyncClient() as session:
                    resp = await session.get(profile_url, timeout=10.0)
                    if resp.status_code == 200:
                        content_parts.append(
                            "✅ Available via Tabular API (can be queried)"
                        )
                    else:
                        content_parts.append(
                            "⚠️  Not available via Tabular API (may not be tabular data)"
                        )
            except Exception:  # noqa: BLE001
                content_parts.append("⚠️  Could not check Tabular API availability")
    
            return "\n".join(content_parts)
    
        except httpx.HTTPStatusError as e:
            return f"Error: HTTP {e.response.status_code} - {str(e)}"
        except Exception as e:  # noqa: BLE001
            return f"Error: {str(e)}"
  • The registration function that defines the tool using @mcp.tool() decorator within FastMCP.
    def register_get_resource_info_tool(mcp: FastMCP) -> None:
        @mcp.tool()
        async def get_resource_info(resource_id: str) -> str:
            """
            Get detailed information about a specific resource (file).
    
            Returns comprehensive metadata including format, size, MIME type, URL,
            and associated dataset information. Also checks if the resource is available
            via the Tabular API (data.gouv.fr's API for parsing tabular files without
            downloading them).
    
            Use this tool to determine which data querying tool to use:
            - If available via Tabular API: use query_resource_data (faster, no download needed)
            - If not available or too large: use download_and_parse_resource
    
            Typical workflow:
            1. Use list_dataset_resources to find resources in a dataset
            2. Use get_resource_info to check resource details and Tabular API availability
            3. Use query_resource_data or download_and_parse_resource based on availability
    
            Args:
                resource_id: The ID of the resource to get information about (obtained from list_dataset_resources)
    
            Returns:
                Formatted text with detailed resource information, including Tabular API availability status
            """
            try:
                # Get full resource data from API v2
                resource_data = await datagouv_api_client.get_resource_details(resource_id)
                resource = resource_data.get("resource", {})
                if not resource.get("id"):
                    return f"Error: Resource with ID '{resource_id}' not found."
    
                resource_title = resource.get("title") or resource.get("name") or "Unknown"
    
                content_parts = [
                    f"Resource Information: {resource_title}",
                    "",
                    f"Resource ID: {resource_id}",
                ]
    
                if resource.get("format"):
                    content_parts.append(f"Format: {resource.get('format')}")
    
                if resource.get("filesize"):
                    size = resource.get("filesize")
                    if isinstance(size, int):
                        # Format size in human-readable format
                        if size < 1024:
                            size_str = f"{size} B"
                        elif size < 1024 * 1024:
                            size_str = f"{size / 1024:.1f} KB"
                        elif size < 1024 * 1024 * 1024:
                            size_str = f"{size / (1024 * 1024):.1f} MB"
                        else:
                            size_str = f"{size / (1024 * 1024 * 1024):.1f} GB"
                        content_parts.append(f"Size: {size_str}")
    
                if resource.get("mime"):
                    content_parts.append(f"MIME type: {resource.get('mime')}")
    
                if resource.get("type"):
                    content_parts.append(f"Type: {resource.get('type')}")
    
                if resource.get("url"):
                    content_parts.append("")
                    content_parts.append(f"URL: {resource.get('url')}")
    
                if resource.get("description"):
                    content_parts.append("")
                    content_parts.append(f"Description: {resource.get('description')}")
    
                # Dataset information
                dataset_id = resource_data.get("dataset_id")
                if dataset_id:
                    content_parts.append("")
                    content_parts.append(f"Dataset ID: {dataset_id}")
                    try:
                        dataset_meta = await datagouv_api_client.get_dataset_metadata(
                            str(dataset_id)
                        )
                        if dataset_meta.get("title"):
                            content_parts.append(f"Dataset: {dataset_meta.get('title')}")
                    except Exception:  # noqa: BLE001
                        pass
    
                # Check if resource is available via Tabular API
                content_parts.append("")
                try:
                    # Try to get profile to check if it's tabular
                    profile_url = f"{env_config.get_base_url('tabular_api')}resources/{resource_id}/profile/"
                    async with httpx.AsyncClient() as session:
                        resp = await session.get(profile_url, timeout=10.0)
                        if resp.status_code == 200:
                            content_parts.append(
                                "✅ Available via Tabular API (can be queried)"
                            )
                        else:
                            content_parts.append(
                                "⚠️  Not available via Tabular API (may not be tabular data)"
                            )
                except Exception:  # noqa: BLE001
                    content_parts.append("⚠️  Could not check Tabular API availability")
    
                return "\n".join(content_parts)
    
            except httpx.HTTPStatusError as e:
                return f"Error: HTTP {e.response.status_code} - {str(e)}"
            except Exception as e:  # noqa: BLE001
                return f"Error: {str(e)}"
  • Top-level registration function that calls register_get_resource_info_tool(mcp) to register the tool among others.
    def register_tools(mcp: FastMCP) -> None:
        """Register all MCP tools with the provided FastMCP instance."""
        register_search_datasets_tool(mcp)
        register_query_resource_data_tool(mcp)
        register_get_dataset_info_tool(mcp)
        register_list_dataset_resources_tool(mcp)
        register_get_resource_info_tool(mcp)
        register_download_and_parse_resource_tool(mcp)
        register_get_metrics_tool(mcp)
  • Input schema: resource_id (str); Output: str with formatted resource info. Detailed docstring describes usage and workflow.
    async def get_resource_info(resource_id: str) -> str:
        """
        Get detailed information about a specific resource (file).
    
        Returns comprehensive metadata including format, size, MIME type, URL,
        and associated dataset information. Also checks if the resource is available
        via the Tabular API (data.gouv.fr's API for parsing tabular files without
        downloading them).
    
        Use this tool to determine which data querying tool to use:
        - If available via Tabular API: use query_resource_data (faster, no download needed)
        - If not available or too large: use download_and_parse_resource
    
        Typical workflow:
        1. Use list_dataset_resources to find resources in a dataset
        2. Use get_resource_info to check resource details and Tabular API availability
        3. Use query_resource_data or download_and_parse_resource based on availability
    
        Args:
            resource_id: The ID of the resource to get information about (obtained from list_dataset_resources)
    
        Returns:
            Formatted text with detailed resource information, including Tabular API availability status
        """
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes what the tool returns (comprehensive metadata including format, size, MIME type, URL, dataset information, and Tabular API availability status) and its role in determining subsequent actions. However, it doesn't mention potential limitations like rate limits or authentication 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?

The description is well-structured with clear sections for purpose, usage guidelines, workflow, arguments, and returns. Every sentence adds value, though it could be slightly more concise by integrating the workflow into the usage guidelines rather than as a separate section.

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

Completeness5/5

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

Given the tool's complexity (single parameter but with important decision-making role), no annotations, and the presence of an output schema, the description is complete. It explains the tool's purpose, usage context, parameter semantics, return value implications, and relationship to sibling tools, providing everything needed for an agent to use it effectively.

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?

With 0% schema description coverage for the single parameter, the description compensates by explaining the semantics of resource_id: 'The ID of the resource to get information about (obtained from list_dataset_resources)'. This provides crucial context about where to obtain the parameter value, though it doesn't specify format constraints or validation rules.

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 specific action ('Get detailed information about a specific resource (file)') and distinguishes it from siblings by specifying it returns comprehensive metadata and checks Tabular API availability. It explicitly differentiates from query_resource_data and download_and_parse_resource by explaining its role in determining which of those tools to use.

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?

The description provides explicit guidance on when to use this tool vs alternatives, stating 'Use this tool to determine which data querying tool to use' and listing specific conditions for using query_resource_data or download_and_parse_resource. It also provides a typical workflow showing its position in a sequence with list_dataset_resources.

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/datagouv/datagouv-mcp'

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