get_street_level_crimes
Retrieve street-level crime data for any location in England, Wales, and Northern Ireland. Specify coordinates or a custom polygon area, filter by date and category, and get detailed crime records.
Instructions
Retrieve street-level crimes by lat/lng or custom polygon area
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| lat | No | Latitude of the requested crime area | |
| lng | No | Longitude of the requested crime area | |
| poly | No | The lat/lng pairs defining the boundary of the custom area | |
| date | No | Limit results to a specific month (YYYY-MM) | |
| category | No | The crime category | all-crime |
Implementation Reference
- src/index.ts:272-288 (handler)Handler function for 'get_street_level_crimes'. Extracts lat/lng/poly/date/category from args, builds query params, calls the police.uk API endpoint 'crimes-street/{category}' via the makeApiRequest helper, and returns the results or empty array.
async function getStreetLevelCrimes(args: any) { const { lat, lng, poly, date, category = 'all-crime' } = args; const params: Record<string, any> = {}; if (date) params.date = date; if (lat && lng) { params.lat = lat; params.lng = lng; } else if (poly) { params.poly = poly; } else { return []; } const endpoint = `crimes-street/${category}`; return await makeApiRequest(endpoint, params) || []; } - src/index.ts:25-37 (schema)Schema registration for 'get_street_level_crimes' tool. Defines the name, description, and inputSchema with optional properties: lat (number), lng (number), poly (string), date (string), category (string, default 'all-crime').
name: 'get_street_level_crimes', description: 'Retrieve street-level crimes by lat/lng or custom polygon area', inputSchema: { type: 'object', properties: { lat: { type: 'number', description: 'Latitude of the requested crime area' }, lng: { type: 'number', description: 'Longitude of the requested crime area' }, poly: { type: 'string', description: 'The lat/lng pairs defining the boundary of the custom area' }, date: { type: 'string', description: 'Limit results to a specific month (YYYY-MM)' }, category: { type: 'string', description: 'The crime category', default: 'all-crime' } } } }, - src/index.ts:448-448 (registration)Tool function mapping that maps the tool name 'get_street_level_crimes' to the handler function getStreetLevelCrimes. Used at runtime by the CallToolRequestSchema handler to dispatch tool calls.
get_street_level_crimes: getStreetLevelCrimes, - src/index.ts:9-20 (helper)Helper function makeApiRequest that performs the actual HTTP GET request to the police.uk API base URL with the given endpoint and parameters. Used by the getStreetLevelCrimes handler to fetch crime data.
async function makeApiRequest(endpoint: string, params?: Record<string, any>) { const baseUrl = 'https://data.police.uk/api'; const url = `${baseUrl}/${endpoint}`; try { const response = await axios.get(url, { params, timeout: 10000 }); return response.data; } catch (error) { console.error(`API request failed: ${error}`); return null; } }