Skip to main content
Glama
curtis-d-williams

mcp-license-header-guardian

check_license_header

Verify Python files in a git repository contain required license headers in the first five lines, checking for Copyright or SPDX-License-Identifier text without network access or file modifications.

Instructions

Deterministic, network-free, read-only Tier 1 guardian.

Checks .py files tracked by git to ensure the first 5 lines contain "Copyright" OR "SPDX-License-Identifier".

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_pathYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The implementation of the check_license_header tool which checks if .py files tracked by git contain a copyright notice or SPDX-License-Identifier in the first 5 lines.
    def check_license_header(repo_path: str) -> Dict[str, Any]:
        """
        Deterministic, network-free, read-only Tier 1 guardian.
    
        Checks .py files tracked by git to ensure the first 5 lines contain
        "Copyright" OR "SPDX-License-Identifier".
        """
        if not _repo_path_is_valid(repo_path):
            return _fail_closed("fail-closed: invalid_repo_path", repo_path)
    
        abs_repo = os.path.abspath(repo_path)
    
        try:
            tracked = _run_git_ls_files(abs_repo)
        except RuntimeError as e:
            return _fail_closed(f"fail-closed: {str(e)}", repo_path, output={"files_missing_header": [], "notes": ["git ls-files failed"]})
    
        py_files = [p for p in tracked if p.endswith(".py")]
        missing: List[str] = []
    
        for rel in py_files:
            full = os.path.join(abs_repo, rel)
            if not _first_n_lines_contains_required_marker(full, n=5):
                missing.append(rel)
    
        missing.sort()
    
        output = {
            "files_missing_header": missing,
            "notes": [
                "scope: tracked .py files only",
                "rule: first 5 lines contain Copyright OR SPDX-License-Identifier",
                "listing: git ls-files",
            ],
        }
    
        if missing:
            return {
                "tool": "check_license_header",
                "repo_path": repo_path,
                "ok": False,
                "fail_closed": True,
                "details": "fail-closed: missing_license_header",
                "output": output,
            }
    
        return {
            "tool": "check_license_header",
            "repo_path": repo_path,
            "ok": True,
            "fail_closed": False,
            "details": "ok",
            "output": output,
        }
  • MCP tool registration for check_license_header.
    @mcp.tool()
  • Helper function that checks if the first N lines of a file contain the required license markers.
    def _first_n_lines_contains_required_marker(path: str, n: int = 5) -> bool:
        try:
            with open(path, "rb") as f:
                raw = f.read(8192)
        except Exception:
            return False
    
        text = raw.decode("utf-8", errors="replace")
        lines = text.splitlines()[:n]
        for line in lines:
            if "Copyright" in line or "SPDX-License-Identifier" in line:
                return True
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 key traits: deterministic, network-free, read-only, and Tier 1 guardian (implying low-risk or foundational). This covers safety and operational context well, though it could add more on error handling or output format.

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?

The description is highly concise and well-structured, with two sentences that front-load key information (deterministic, network-free, read-only) and then specify the action and criteria. Every sentence adds value without waste.

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?

Given the tool's moderate complexity (1 parameter, no annotations, but with an output schema), the description is mostly complete. It covers purpose, behavior, and scope, but lacks details on the parameter and output. Since an output schema exists, explaining return values is less critical, but the parameter gap slightly reduces completeness.

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?

The schema description coverage is 0%, so the description must compensate. It does not explicitly mention the 'repo_path' parameter, but it implies the context ('.py files tracked by git'), which relates to repository paths. This adds some semantic meaning beyond the bare schema, though not directly naming or detailing the parameter.

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 ('checks .py files tracked by git') and resources ('.py files'), and distinguishes its scope (first 5 lines for specific license headers). It explicitly defines the deterministic, network-free, read-only nature, making it highly specific and self-contained.

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 description implies usage context (checking license headers in Python files under git) but does not provide explicit guidance on when to use this tool versus alternatives, prerequisites, or exclusions. Since there are no sibling tools, the lack of comparative guidance is less critical, but it still lacks detailed usage instructions.

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/curtis-d-williams/mcp-license-header-guardian'

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