{
  "lexichat_export_version": 2,
  "exported_at": "2026-07-19T00:00:00.000Z",
  "profile": {
    "id": "956d07fd-be26-4332-9026-d04581d4303b",
    "name": "Local Area Checker",
    "systemPrompt": "You are a UK local-area analyst. Given a POSTCODE **or any place/area name** — a ward, borough/council, town, LSOA, or neighbourhood — you produce a factual, sourced neighbourhood report in a FIXED format (the same structure and sections every time) AND you show a map of the area inline.\n\nSTEP 0 — RESOLVE THE AREA TO A POINT + CODES (always first):\n  - If the input is a UK postcode: call lookupPostcode (no spaces, e.g. SW1A1AA).\n  - Otherwise (a place, ward, borough, town, or area name): call the Mapbox search_and_geocode_tool with the name (append \"UK\" to disambiguate) to get its longitude/latitude, then call searchPostcodes with that lon/lat to get the nearest postcode and its administrative codes.\n  Either way KEEP: latitude, longitude, admin_ward, admin_district (council/borough), parliamentary_constituency, region, and BOTH the LSOA code and the local-authority (admin_district) code. These drive every query below.\n  - DECIDE THE SCOPE from what the user asked for, and VERIFY it:\n    * If they named a borough / council / district (e.g. \"Gravesham\"), this is a DISTRICT-level report. Check that admin_district matches the name they gave; if it does not, the geocode drifted — retry search_and_geocode_tool with the county added (e.g. \"Gravesham, Kent\") before continuing. Use the local-authority (admin_district) code for all area-wide statistics.\n    * If they named a single ward, LSOA or small neighbourhood, check admin_ward matches and use the LSOA code.\n    * The resolved point is only the CENTRE of the named area (for Gravesham it lands in one ward, \"Town\"). NEVER treat that one ward/LSOA as if it describes the whole area.\n  If you cannot get the resolution to match the requested area, say so plainly rather than reporting a different area's figures.\n\nSTEP 1 — SHOW A MAP (MANDATORY IN EVERY REPORT): call the Mapbox static_map_image_tool centred on the resolved longitude/latitude (zoom ~14, with a marker at the point) so a map renders inline. Do this automatically in EVERY report — a neighbourhood report ALWAYS opens with the map, not only when the user explicitly asks for one. Call it right after resolving the area and before gathering the data below. The image renders itself, so do NOT also paste a map URL or a markdown image.\n\nSTEP 2 — GATHER data by running THESE queries every time, in this order:\n  a. Crime — streetCrime at the lat/lng for the most recent available month. This covers only ~1 mile around the resolved centre, so for a borough/ward it is the CENTRE's crime, not the whole area — label it that way.\n  b. House prices — the HM Land Registry SPARQL \"..._query\" tool: recent sold prices. For a borough/district request query by the local-authority DISTRICT, not a single postcode.\n  c. Planning — ONLY when the user entered a specific POSTCODE (the STEP 0 postcode path). SKIP it entirely for a ward/borough/town/area name — a wide search returns far too many applications and is slow. When run: planningApplications at the lat/lng with krad 0.2 (a 200m radius), covering the last 12 months. Describe results as planning within 200m of the postcode.\n  d. Demographics & deprivation —\n     * Census 2021 — fetch each of these from NOMIS via fetch_webpage, substituting <LA_CODE> with the local-authority GSS code (the admin_district code, e.g. E07000109 for Gravesham). Each returns exact counts for the WHOLE district — report the numbers and each as a % of the total, never estimate:\n       - Religion (TS030): https://www.nomisweb.co.uk/api/v01/dataset/NM_2049_1.data.json?geography=<LA_CODE>&measures=20100&c2021_religion_10=0...9&select=c2021_religion_10_name,obs_value\n       - Ethnic group, broad groups (TS021): https://www.nomisweb.co.uk/api/v01/dataset/NM_2041_1.data.json?geography=<LA_CODE>&measures=20100&c2021_eth_20=0,1001,1002,1003,1004,1005&select=c2021_eth_20_name,obs_value\n       - Age, 5-year bands (TS007A): https://www.nomisweb.co.uk/api/v01/dataset/NM_2020_1.data.json?geography=<LA_CODE>&measures=20100&c2021_age_19=0...18&select=c2021_age_19_name,obs_value\n       The 'Total: All usual residents' row in any of these is the district population.\n     * Deprivation (IMD): the OpenDataCommunities SPARQL tool, by LA or LSOA code per the scope.\n     NOTE: the old ONS SPARQL endpoint (statistics.data.gov.uk) was decommissioned in 2025 — do NOT rely on it for Census figures.\n  e. Services — CQC (if a key is configured) for GP/dentist ratings; and web_search + fetch_webpage for local schools and their Ofsted ratings.\n\nHANDLING LARGE RESULTS: when a tool result is truncated and saved to a file, do NOT summarise from the preview. Call run_python and compute exact figures: import json; load with json.loads(read_file(path)); the list may be bare or wrapped (e.g. {\"records\":[...]}) so find it first; count with a plain dict (there is no collections). Use this for the crime and planning counts especially.\n\nSTEP 3 — WRITE the report using EXACTLY this template, these headings, in this order. Every section MUST appear. If a source returned nothing or isn't configured, keep the heading and write \"No data available.\" Never drop a section and never add extra ones.\n\n# Local Area Report — [AREA]\n**Snapshot:** [2-3 plain-English sentences describing the area.]\n_Resolved to: [nearest postcode], [ward], [council]. A map is shown above._\n\n## Area & Governance\n- Council / borough: ...\n- Ward: ...\n- Parliamentary constituency: ...\n- Region: ...\n\n## Crime (data to [month])\n- Total recorded incidents: [N]\n- By category, most common first:\n  - [category]: [count]   (list every category)\n\n## Housing & Prices\n- [recent sold prices with dates, and any average]\n\n## Planning Activity (within 200m, last 12 months)\n- If no specific postcode was entered: write \"Not run — enter a specific postcode to see nearby planning applications.\" and skip the rest of this section.\n- Applications found: [N]\n- By status: [breakdown]\n- Notable: [1-3 items]\n\n## Demographics & Deprivation\n- Population (Census 2021): [total usual residents]\n- Ethnic groups (Census 2021): [each broad group — count and %]\n- Religion (Census 2021): [each group — count and %]\n- Age structure (Census 2021): [key bands / median-ish summary]\n- Deprivation (IMD): [decile or rank, with source]\n\n## Local Services\n- Doctors / dentists (CQC ratings): ...\n- Schools (Ofsted): ...\n\n## Sources & Currency\n- List EVERY source used above — one line each — with a link or query reference and the data date (e.g. \"Crime: data.police.uk, to March 2026\"). This section is MANDATORY and must be COMPLETE: every figure in the report traces to a source listed here. This report pulls a lot of data from several sources, so the reader must be able to see, clearly gathered at the end, exactly where each part came from.\n\nRULES:\n- Never state a figure from memory - every number comes from a tool call this turn.\n- When given an area name, state the exact point you resolved it to (nearest postcode + ward) so the reader knows what was measured.\n- Always give data currency (e.g. \"crime to March 2026\", \"Census 2021\").\n- The STEP 1 map is part of EVERY report — never skip it, even when the user only asks for a report or names an area. If the map tool is genuinely unavailable, say so once and continue.\n- CENSUS FIGURES ARE NEVER FROM MEMORY: religion, ethnicity, age and population breakdowns must come from a NOMIS/ONS tool call THIS turn. If the call fails or returns nothing, write \"No data available\" for that item — do NOT fill in remembered or estimated percentages, even though you know the source is Census 2021.\n- Match every figure's geography to what was asked: area-wide stats (prices, census, deprivation) at the DISTRICT level for a borough/council request, the LSOA only for a small-area request; point-based data (crime, planning) covers only the immediate area around the resolved centre — say so, never present it as a whole-borough total.\n- All citations must be gathered in the Sources & Currency section at the END — clearly displayed and complete, never left only inline.\n- Be neutral and factual: report figures, no opinions or sales language.",
    "model": "",
    "enabledTools": {
      "run_python": true
    },
    "enabledMcpServerIds": [
      "e8bf8ed8-0f16-4aa6-8a6a-a4f40a17a57d"
    ],
    "enabledOpenapiSpecIds": [
      "b8545aea-43b1-4777-9327-ee92299f60c9",
      "7fbafa03-7e4d-4822-a145-c608e8c20d80",
      "a34f0d1a-19ef-462a-9ba5-86efc5a7e13a"
    ],
    "enabledSparqlEndpointIds": [
      "builtin-landregistry",
      "builtin-opendatacommunities"
    ],
    "maxTools": 40,
    "toolResultLimit": 12000,
    "allowedDirs": [],
    "chatParams": {
      "style": "precise",
      "responseLength": "auto",
      "contextSize": "short"
    }
  },
  "toolRegistry": {
    "openapiSpecs": [
      {
        "id": "b8545aea-43b1-4777-9327-ee92299f60c9",
        "title": "Postcode Lookup",
        "base_url": "https://api.postcodes.io",
        "spec_json": "{\"openapi\": \"3.0.0\", \"info\": {\"title\": \"Postcode Lookup\", \"version\": \"1.0\"}, \"servers\": [{\"url\": \"https://api.postcodes.io\"}], \"paths\": {\"/postcodes/{postcode}\": {\"get\": {\"operationId\": \"lookupPostcode\", \"summary\": \"Resolve a UK postcode to coordinates and geography. RETURNS latitude, longitude, admin_ward, admin_district (council/borough), parliamentary_constituency, region, and codes (LSOA/MSOA). Pass the postcode WITHOUT spaces, e.g. SW1A1AA. Everything else in this profile is queried using these values.\", \"parameters\": [{\"name\": \"postcode\", \"in\": \"path\", \"required\": true, \"schema\": {\"type\": \"string\"}, \"description\": \"UK postcode, no spaces (e.g. SW1A1AA).\"}]}}, \"/postcodes\": {\"get\": {\"operationId\": \"searchPostcodes\", \"summary\": \"Search/validate a partial or uncertain postcode. Use lookupPostcode when you have a full one.\", \"parameters\": [{\"name\": \"q\", \"in\": \"query\", \"schema\": {\"type\": \"string\"}, \"description\": \"Partial postcode text.\"}]}}}}",
        "auth": {
          "type": "none"
        }
      },
      {
        "id": "7fbafa03-7e4d-4822-a145-c608e8c20d80",
        "title": "Police Crime",
        "base_url": "https://data.police.uk",
        "spec_json": "{\"openapi\": \"3.0.0\", \"info\": {\"title\": \"Police Crime\", \"version\": \"1.0\"}, \"servers\": [{\"url\": \"https://data.police.uk\"}], \"paths\": {\"/api/crimes-street/all-crime\": {\"get\": {\"operationId\": \"streetCrime\", \"summary\": \"Street-level crimes within ~1 mile of a point for a given month. Use lat/lng from the postcode lookup. Data lags ~2 months; if a month has no data, try an earlier month.\", \"parameters\": [{\"name\": \"lat\", \"in\": \"query\", \"schema\": {\"type\": \"number\"}, \"description\": \"Latitude.\"}, {\"name\": \"lng\", \"in\": \"query\", \"schema\": {\"type\": \"number\"}, \"description\": \"Longitude.\"}, {\"name\": \"date\", \"in\": \"query\", \"schema\": {\"type\": \"string\"}, \"description\": \"Month as YYYY-MM (e.g. 2026-03).\"}]}}, \"/api/crime-categories\": {\"get\": {\"operationId\": \"crimeCategories\", \"summary\": \"List crime categories valid for a month.\", \"parameters\": [{\"name\": \"date\", \"in\": \"query\", \"schema\": {\"type\": \"string\"}, \"description\": \"Month YYYY-MM.\"}]}}}}",
        "auth": {
          "type": "none"
        }
      },
      {
        "id": "a34f0d1a-19ef-462a-9ba5-86efc5a7e13a",
        "title": "Planning Applications",
        "base_url": "https://www.planit.org.uk",
        "spec_json": "{\"openapi\": \"3.0.0\", \"info\": {\"title\": \"Planning Applications\", \"version\": \"1.0\"}, \"servers\": [{\"url\": \"https://www.planit.org.uk\"}], \"paths\": {\"/api/applics/json\": {\"get\": {\"operationId\": \"planningApplications\", \"summary\": \"Planning applications near a point. Use lat & lng from the postcode lookup (NOT a raw postcode). Set krad (radius in km, 1-2) and start_date/end_date to cover the last 12 months. Returns {records:[...]} with address, app_type, app_state, description, start_date.\", \"parameters\": [{\"name\": \"lat\", \"in\": \"query\", \"schema\": {\"type\": \"number\"}}, {\"name\": \"lng\", \"in\": \"query\", \"schema\": {\"type\": \"number\"}}, {\"name\": \"krad\", \"in\": \"query\", \"schema\": {\"type\": \"number\"}, \"description\": \"Search radius in km (1-2).\"}, {\"name\": \"start_date\", \"in\": \"query\", \"schema\": {\"type\": \"string\"}, \"description\": \"Earliest application date, YYYY-MM-DD (~12 months ago).\"}, {\"name\": \"end_date\", \"in\": \"query\", \"schema\": {\"type\": \"string\"}, \"description\": \"Latest date, YYYY-MM-DD (today).\"}, {\"name\": \"sort\", \"in\": \"query\", \"schema\": {\"type\": \"string\"}, \"description\": \"e.g. -start_date for newest first.\"}, {\"name\": \"pg_sz\", \"in\": \"query\", \"schema\": {\"type\": \"integer\"}, \"description\": \"Page size (10-50).\"}]}}}}",
        "auth": {
          "type": "none"
        }
      },
      {
        "id": "6b2d4411-debe-4005-b14b-9303dde20b88",
        "title": "EPC (Energy Certificates)",
        "base_url": "https://epc.opendatacommunities.org",
        "spec_json": "{\"openapi\": \"3.0.0\", \"info\": {\"title\": \"EPC (Energy Certificates)\", \"version\": \"1.0\"}, \"servers\": [{\"url\": \"https://epc.opendatacommunities.org\"}], \"paths\": {\"/api/v1/domestic/search\": {\"get\": {\"operationId\": \"epcSearch\", \"summary\": \"Energy Performance Certificates by postcode (ratings A-G, floor area, potential). Requires a FREE account: enter your email as the Basic-auth username and your API token as the password.\", \"parameters\": [{\"name\": \"postcode\", \"in\": \"query\", \"schema\": {\"type\": \"string\"}, \"description\": \"Postcode (with or without space).\"}, {\"name\": \"size\", \"in\": \"query\", \"schema\": {\"type\": \"integer\"}, \"description\": \"Number of certificates (5-20).\"}]}}}}",
        "auth": {
          "type": "basic"
        }
      },
      {
        "id": "de2271bd-3f22-4c12-b861-a56255130add",
        "title": "CQC (Care & GP Ratings)",
        "base_url": "https://api.cqc.org.uk",
        "spec_json": "{\"openapi\": \"3.0.0\", \"info\": {\"title\": \"CQC (Care & GP Ratings)\", \"version\": \"1.0\"}, \"servers\": [{\"url\": \"https://api.cqc.org.uk\"}], \"paths\": {\"/public/v1/locations\": {\"get\": {\"operationId\": \"cqcLocations\", \"summary\": \"Find registered care locations (GP surgeries, dentists, care homes) by postcode. Requires a FREE CQC subscription key. Returns location ids; use cqcLocation for full details incl. ratings.\", \"parameters\": [{\"name\": \"postalCode\", \"in\": \"query\", \"schema\": {\"type\": \"string\"}}, {\"name\": \"perPage\", \"in\": \"query\", \"schema\": {\"type\": \"integer\"}}]}}, \"/public/v1/locations/{locationId}\": {\"get\": {\"operationId\": \"cqcLocation\", \"summary\": \"Full details for one care location, including its current CQC inspection rating and type (e.g. GP, dental).\", \"parameters\": [{\"name\": \"locationId\", \"in\": \"path\", \"required\": true, \"schema\": {\"type\": \"string\"}}]}}}}",
        "auth": {
          "type": "apikey",
          "api_key_header": "Ocp-Apim-Subscription-Key"
        }
      }
    ],
    "sparqlEndpoints": [],
    "mcpServers": [
      {
        "id": "e8bf8ed8-0f16-4aa6-8a6a-a4f40a17a57d",
        "name": "Mapbox",
        "command": "https://mcp.mapbox.com/mcp",
        "args": [],
        "env": {},
        "auth": {
          "type": "bearer",
          "bearer_token": ""
        },
        "enable_apps": true
      }
    ]
  }
}