pbs_api
Retrieve Australian Pharmaceutical Benefits Scheme (PBS) data on medicines, pricing, and availability through API endpoints. Use this tool to access information programmatically.
Instructions
Access the Australian Pharmaceutical Benefits Scheme (PBS) API to retrieve information about medicines, pricing, and availability.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| endpoint | Yes | The specific PBS API endpoint to access (e.g., "prescribers", "item-overview") | |
| method | No | HTTP method to use (GET is recommended for most PBS API operations) | GET |
| params | No | Query parameters to include in the request (e.g., {"get_latest_schedule_only": "true"}) | |
| subscriptionKey | No | Custom subscription key (if not provided, the default public key will be used) | |
| timeout | No | Request timeout in milliseconds |
Implementation Reference
- src/tools/pbsApi.ts:136-167 (handler)Core execution logic for the 'pbs_api' tool: constructs API requests to PBS endpoint, handles authentication with subscription key, executes HTTP calls via axios, and formats success/error responses.export async function runPbsApiTool(args: z.infer<typeof PbsApiToolSchema>) { try { const endpoint = args.endpoint || ''; console.error(`Accessing PBS API endpoint: ${args.method} ${endpoint}`); // Use the provided subscription key or fall back to the default const subscriptionKey = args.subscriptionKey || DEFAULT_SUBSCRIPTION_KEY; // Construct the full URL const url = constructUrl(endpoint); // Configure request const config: AxiosRequestConfig = { method: args.method, url: url, headers: { 'Subscription-Key': subscriptionKey, 'Accept': 'application/json' }, params: args.params || {}, timeout: args.timeout }; // Make the request const response = await axios(config); return formatResponse(response); } catch (error) { console.error('PBS API error:', error); return formatErrorResponse(error); } }
- src/tools/pbsApi.ts:21-31 (schema)Zod input schema for validating parameters of the pbs_api tool.export const PbsApiToolSchema = z.object({ endpoint: z.string().describe('The specific PBS API endpoint to access (e.g., "prescribers", "item-overview")'), method: z.enum(['GET', 'POST']).default('GET') .describe('HTTP method to use (GET is recommended for most PBS API operations)'), params: z.record(z.string()).optional() .describe('Query parameters to include in the request (e.g., {"get_latest_schedule_only": "true"})'), subscriptionKey: z.string().optional() .describe('Custom subscription key (if not provided, the default public key will be used)'), timeout: z.number().default(30000) .describe('Request timeout in milliseconds') });
- src/pbsApiServer.ts:14-51 (registration)MCP tool metadata registration: defines the 'pbs_api' tool's name, description, and JSON input schema for ListTools handler.export const pbsApiTools = [ { name: pbsApiToolName, description: pbsApiToolDescription, inputSchema: { type: "object", properties: { endpoint: { type: "string", description: 'The specific PBS API endpoint to access (e.g., "prescribers", "item-overview")' }, method: { type: "string", enum: ["GET", "POST"], default: "GET", description: 'HTTP method to use (GET is recommended for most PBS API operations)' }, params: { type: "object", additionalProperties: { type: "string" }, description: 'Query parameters to include in the request (e.g., {"get_latest_schedule_only": "true"})' }, subscriptionKey: { type: "string", description: 'Custom subscription key (if not provided, the default public key will be used)' }, timeout: { type: "number", default: 30000, description: 'Request timeout in milliseconds' } }, required: ["endpoint"] } } ];
- src/pbsApiServer.ts:54-60 (registration)Tool handler registration: maps 'pbs_api' calls to the core runPbsApiTool function with type casting.export const pbsApiToolHandlers = { [pbsApiToolName]: async (params: unknown) => { // Type cast params to the expected type const typedParams = params as z.infer<typeof PbsApiToolSchema>; return await runPbsApiTool(typedParams); } };
- src/pbsApiServer.ts:79-84 (registration)MCP server registration for ListToolsRequestSchema, returning the pbsApiTools list containing 'pbs_api'.server.setRequestHandler(ListToolsRequestSchema, async () => { console.error(`[PBS API Server DEBUG] Returning tools: ${JSON.stringify(pbsApiTools)}`); return { tools: pbsApiTools, }; });