PBS API

by matthewdcage

4 177 downloads Not rated yet MIT

About

🐍 ☁️ Access Australian Pharmaceutical Benefits Scheme data for medicine information, pricing, and availability. Built with Python and FastAPI.

Details

License
MIT

Explore

This MCP server implements the following Model Context Protocol features:

- Tools: Provides tools for querying the PBS API endpoints, allowing AI models to access pharmaceutical data
- Transport Layers: Supports both stdio and HTTP/SSE transport layers
- Error Handling: Comprehensive error handling for API rate limits and authentication issues
- LLM Integration: Receives tool calls and prompts directly from LLM components, enabling seamless AI interaction with PBS data

The PBS MCP server can be run in different modes:

When running in HTTP mode, the following endpoints are available:

1. Clone this repository:

   git clone <repository-url>
cd pbs-mcp-standalone

2. Install dependencies:

   npm install

3. Build the project:

   npm run build

Here's an example of how to configure this server with an MCP client:

{
  "mcpServers": {
    "pbs-api": {
      "command": "node",
      "args": ["path/to/pbs-mcp-standalone/build/index.js"],
      "env": {
        "PBS_API_SUBSCRIPTION_KEY": "your-subscription-key-here"
      }
    }
  }
}

The tool uses a subscription key for accessing the PBS API. You can obtain your own key by registering on the PBS Developer Portal.

For development purposes, see the .env.example file for configuration details.

This MCP server implements the following Model Context Protocol features:

- Tools: Provides tools for querying the PBS API endpoints, allowing AI models to access pharmaceutical data
- Transport Layers: Supports both stdio and HTTP/SSE transport layers
- Error Handling: Comprehensive error handling for API rate limits and authentication issues
- LLM Integration: Receives tool calls and prompts directly from LLM components, enabling seamless AI interaction with PBS data

The PBS MCP server can be run in different modes:

To use this MCP server as a command-line tool:

1. Build the project:

   npm run build

2. Run the CLI with the desired command:

   npm run cli -- <command>


Or use the start script:
   ./start.sh cli <command>

The PBS API tool can be used with the following parameters:

{
  "endpoint": "prescribers",
  "method": "GET",
  "params": {
    "get_latest_schedule_only": "true",
    "limit": "20"
  }
}

When running in HTTP mode, the following endpoints are available:

GET /tools

Returns a list of available tools.

POST /sse/:toolName

Invokes a tool and sends the result via SSE.

POST /api/:toolName

Invokes a tool and returns the result as JSON.

Obtaining a PBS API Subscription Key

To obtain your own PBS API subscription key, follow these steps:

1. Visit the PBS Data API Portal:
- Go to https://data-api-portal.health.gov.au/

2. Create an Account:
- Click on "Sign Up" to create a new account
- Fill in your details and verify your email address

3. Subscribe to the PBS API:
- Once logged in, navigate to the "Products" section
- Select the "PBS Public API v3" product
- Click "Subscribe" to request access to the API

4. Retrieve Your Subscription Key:
- After your subscription is approved, go to your profile
- Navigate to "Subscriptions" or "API Keys" section
- Copy your primary or secondary key

5. Configure Your Environment:
- Create a .env file based on the .env.example template
- Replace your-subscription-key-here with your actual subscription key:

     PBS_API_SUBSCRIPTION_KEY=your-actual-subscription-key

Note: The PBS Public API is rate-limited to one request per 20 seconds. This limit is shared among all users of the public API. For higher rate limits or access to embargo data (future schedules), you may need to apply for special access through the PBS Developer Program.

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.