This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is an MCP (Model Context Protocol) server that provides semantic interaction with the schema.gov.it SPARQL endpoint. It enables AI agents to explore and analyze Italy's semantic web catalog of public administration ontologies.
npm run build # Compile TypeScript from src/ to dist/
npm start # Run the compiled server (node dist/index.js)No test or lint commands are configured. The project uses TypeScript strict mode for type checking.
Single-file implementation (src/index.ts) using:
@modelcontextprotocol/sdkfor MCP protocol handling over stdiozodfor parameter validation- Direct
fetchcalls to the SPARQL endpoint oxigraph(WASM) for local RDF file loading and SPARQL execution
Base Operations:
query_sparql- Raw SPARQL execution with automatic prefix injectionexplore_catalog- List available graphs/ontologiesexplore_classes- Discover classes with instance counts
Semantic Analytics:
check_coverage- Analyze usage of specific classes/propertiescheck_quality- Find missing labels/descriptionscheck_overlaps- Identify duplicate labels or explicit mappings
Data Model (Ontologies):
list_ontologies- List available ontologies with titlesexplore_ontology- List classes and properties in a specific ontologylist_properties- List ObjectProperty and DatatypeProperty with domain/rangeget_property_details- Full property details (domain, range, inverse, functional)
Controlled Vocabularies:
list_vocabularies- List ConceptSchemes with instance countssearch_in_vocabulary- Search concepts within a specific vocabularybrowse_vocabulary- Paginated browsing of large vocabularies
Catalogs & Datasets:
list_datasets- List DCAT-AP_IT datasetsexplore_dataset- Get dataset details and distributionspreview_distribution- Download and preview first rows of CSV/JSON data
Note: keep these tools available, but do not treat them as the default entry point for schema.gov.it. In this catalog, many DCAT-AP_IT datasets are semantic assets such as ontologies, controlled vocabularies, and their distributions. For schema.gov.it, prefer ontology, vocabulary, class/property, and SPARQL tools first; dataset tools are more useful for external catalogs or specific DCAT-AP_IT inspection tasks.
Intelligent Tools:
search_concepts- Fuzzy keyword search (use when URI is unknown)inspect_concept- Deep profiling (definition, hierarchy, usage, relations)find_relations- Discover paths between two concepts (direct or 1-hop)suggest_improvements- Detect orphan classes and cyclesdescribe_resource- Concise Bounded Description (all RDF triples for a resource)
Territorial (OntoPiA):
list_municipalities- Italian municipalities with ISTAT/Belfiore codes (paginated)list_provinces- Italian provinces with codeslist_identifiers- CLV Identifier resources by type
Linked SPARQL Endpoints:
list_linked_endpoints- Discoverdcat:DataServiceendpoints in the catalogquery_external_endpoint- Execute SPARQL against any public HTTPS endpointfind_external_alignments- Find owl:sameAs / skos:*Match links toward external systemsexplore_external_endpoint- Explore classes/counts of an external SPARQL endpoint
Local Ontology (Group K):
inspect_local_ontology- Load and summarize an ontology from a server-local path, inline RDF content, orupload_idquery_local_ontology- Execute SPARQL SELECT against an ontology reachable by the server or previously uploaded via HTTPcompare_local_with_remote- Compare classes/properties from a server-local or uploaded ontology against schema.gov.it
Remote HTTP note: file_path always refers to the MCP server filesystem. If the file lives on the client machine, use POST /upload and pass the returned upload_id instead of retrying local path variants.
Meta:
suggest_new_tools- Analyze usage logs to suggest new specialized toolsanalyze_usage- Parseusage_log.jsonlfor patterns and errors
Automatic SPARQL Prefixes: Internal queries receive these prefixes automatically:
rdf, rdfs, owl, skos, dct, xsd, dcat, foaf, clv, cpv, l0, sm
External endpoint queries do NOT inject prefixes by default (injectPrefixes: false).
Input Sanitization: All user-provided parameters are sanitized before SPARQL interpolation (string escaping for literals, URI validation for URIs via sanitizeSparqlUri()).
Result Compression: Large results (>5 items) use tabular format (headers + rows) for token efficiency.
Usage Logging: All tool calls are logged to usage_log.jsonl with timestamp, tool name, args, and result status.
Timeout: External endpoint queries use a 15-second AbortController timeout. Internal queries use 30 seconds. Implemented via the executeSparql(query, endpoint?, injectPrefixes?, timeoutMs?) signature.
Primary: https://schema.gov.it/sparql
External endpoints (via Linked SPARQL Endpoints tools): any public HTTPS SPARQL endpoint, validated by sanitizeSparqlUri() before use.
The endpoint hosts Italian public administration ontologies including concepts for organizations, services, professional registers, and controlled vocabularies.
The dist/ directory is NOT committed to the repository. It is built automatically via the prepare script when installing from git:
npx -y github:mfortini/schema-gov-it-mcpThe "files": ["dist"] field in package.json ensures only the compiled output is included when publishing to npm.