pbs_api
Retrieve Australian Pharmaceutical Benefits Scheme (PBS) data on medicines, pricing, and availability through API endpoints for healthcare information access.
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 handler function that executes the pbs_api tool: constructs and sends HTTP requests to the PBS API, formats responses and handles errors.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 schema defining the input parameters for 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)Registers the pbs_api tool with its name, description, and JSON input schema for MCP.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)Maps the pbs_api tool name to its handler function (wrapper around runPbsApiTool).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/index.ts:20-25 (registration)Main server creation that registers the pbsApiTools and pbsApiToolHandlers for the MCP server.const server = createMCPServer( "pbs-mcp-standalone", "1.0.0", pbsApiTools, pbsApiToolHandlers );
- src/tools/pbsApi.ts:11-13 (helper)Exports the tool name 'pbs_api' and its description.export const pbsApiToolName = "pbs_api"; export const pbsApiToolDescription = "Access the Australian Pharmaceutical Benefits Scheme (PBS) API to retrieve information about medicines, pricing, and availability.";