get_stop_searches_by_force
Retrieve stop and search records reported by a specific UK police force using the force ID. Optionally filter by month (YYYY-MM) to narrow results.
Instructions
Retrieve stop and searches reported by a specific force
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| force_id | Yes | The unique identifier for the force | |
| date | No | Specific month (YYYY-MM) |
Implementation Reference
- src/index.ts:439-444 (handler)The function that executes the tool logic for 'get_stop_searches_by_force'. It extracts force_id and optional date from args, builds query params, and calls the UK Police API 'stops-force' endpoint via makeApiRequest.
async function getStopSearchesByForce(args: any) { const { force_id, date } = args; const params: Record<string, any> = { force: force_id }; if (date) params.date = date; return await makeApiRequest('stops-force', params) || []; } - src/index.ts:257-268 (schema)Input schema definition for the 'get_stop_searches_by_force' tool. Defines 'force_id' (required) and 'date' (optional, YYYY-MM) as input parameters.
{ name: 'get_stop_searches_by_force', description: 'Retrieve stop and searches reported by a specific force', inputSchema: { type: 'object', properties: { force_id: { type: 'string', description: 'The unique identifier for the force' }, date: { type: 'string', description: 'Specific month (YYYY-MM)' } }, required: ['force_id'] } } - src/index.ts:447-468 (registration)Maps the tool name 'get_stop_searches_by_force' to its handler function getStopSearchesByForce in the toolFunctions object, which is used by the CallToolRequestSchema handler.
const toolFunctions = { get_street_level_crimes: getStreetLevelCrimes, get_street_level_outcomes: getStreetLevelOutcomes, get_crimes_at_location: getCrimesAtLocation, get_crimes_no_location: getCrimesNoLocation, get_crime_categories: getCrimeCategories, get_last_updated: getLastUpdated, get_outcomes_for_crime: getOutcomesForCrime, get_list_of_forces: getListOfForces, get_force_details: getForceDetails, get_senior_officers: getSeniorOfficers, get_neighbourhoods: getNeighbourhoods, get_neighbourhood_details: getNeighbourhoodDetails, get_neighbourhood_boundary: getNeighbourhoodBoundary, get_neighbourhood_team: getNeighbourhoodTeam, get_neighbourhood_events: getNeighbourhoodEvents, get_neighbourhood_priorities: getNeighbourhoodPriorities, locate_neighbourhood: locateNeighbourhood, get_stop_searches_by_area: getStopSearchesByArea, get_stop_searches_by_location: getStopSearchesByLocation, get_stop_searches_no_location: getStopSearchesNoLocation, get_stop_searches_by_force: getStopSearchesByForce - src/index.ts:9-20 (helper)Helper function makeApiRequest used by the handler to call the UK Police API at data.police.uk/api/{endpoint}.
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; } }