MCP Server - Natural Language API Gateway for z-ap-server
This middleware service allows you to interact with the z-ap-server APIs using natural language queries through a FastAPI server. It integrates with Claude desktop on your Mac to process natural language commands.
Setup and Installation
Install the required dependencies:
pip install -r requirements.txt
Configure environment variables (in .env
file):
Z_AP_SERVER_BASE_URL=http://localhost/z-ap-server
API_USERNAME=your_username
API_PASSWORD=your_password
ANTHROPIC_API_KEY= # Optional, leave empty to use Claude desktop
Start the server:
uvicorn main:app --reload
Using Natural Language Interface
The MCP server provides a natural language interface to interact with the z-ap-server's transaction APIs. You can use the /natural_language_request
endpoint to send natural language queries.
With Claude Desktop
Since you have Claude desktop installed on your Mac, the system will automatically use the local Claude app to process your natural language commands when no API key is provided.
Example Queries
Here are some examples of natural language queries you can use:
- "Show me all transactions"
- "Get transaction with ID 3770211"
- "Create a new transaction for user 302960 with amount 50"
- "Update transaction 3770212 to set amount to 25"
- "Delete transaction 3770203"
- "Show me the list of users"
- "What are the transaction types?"
API Endpoint
curl -X POST http://127.0.0.1:8000/natural_language_request \
-H "Content-Type: application/json" \
-d '{"user_input": "Show me all transactions"}'
Web Interface
For a more user-friendly experience, you can access the HTML interface at:
http://127.0.0.1:8000/public/login_test.html
How It Works
- Your natural language request is sent to the MCP server
- The server uses Claude desktop to interpret your request
- Claude maps your request to the appropriate z-ap-server API endpoint
- The server makes the API call with the proper authentication
- Results are returned in a user-friendly format
Available API Actions
The following actions are available through natural language:
get_transactions
: Retrieve a list of transactions
get_transaction
: Retrieve a specific transaction by ID
create_transaction
: Create a new transaction
update_transaction
: Update an existing transaction
delete_transaction
: Delete a transaction
get_users
: Retrieve a list of users
get_transaction_types
: Retrieve a list of transaction types
Security Notes
- The JWT bearer token is currently hardcoded in the application for demonstration purposes
- In a production environment, implement proper token management and security practices