-
Notifications
You must be signed in to change notification settings - Fork 339
update readme for openai playground sample #598
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ Functions to run an MCP server for Twilio API tools | |
|
||
1. Install the [Twilio CLI](https://www.twilio.com/docs/twilio-cli/quickstart#install-twilio-cli) | ||
|
||
Recommended method, homebrew: | ||
Recommended method, homebrew: | ||
```shell | ||
brew tap twilio/brew && brew install twilio | ||
twilio login | ||
|
@@ -70,24 +70,25 @@ twilio serverless:deploy | |
|
||
ℹ️ We're aware of a reported issue with the MCP Inspector project and the authentication header. You'll need to use your MCP client to connect to your deployed MCP server. | ||
|
||
## Integration with MCP clients | ||
|
||
* **URL**: `https://{functions-domain}.twil.io/mcp?services=` | ||
* **Authentication Header**: | ||
* Key: `x-twilio-signature` | ||
* Value: {Valid Twilio signature} | ||
## Generatin Twilio Signature | ||
|
||
### Code samples for generating a Twilio signature | ||
|
||
Learn more about the use of `x-twilio-signature` header for executing `protected` Functions. https://www.twilio.com/docs/serverless/functions-assets/visibility#protected | ||
Learn more about the use of `x-twilio-signature` header for executing `protected` Functions. https://www.twilio.com/docs/serverless/functions-assets/visibility#protected | ||
|
||
The sample code below assuming that the following environment variables are set: | ||
* TWILIO_AUTH_TOKEN | ||
* TWILIO_BASE_DOMAIN | ||
|
||
ℹ️ As the generated signature depends on the full Function endpoint that you are executing, and the URL includes the set of services (e.g. `/mcp?services=PhoneNumbers` vs `/mcp?services=Messaging`), you will need to generate a valid signature every time you update any part of the URL. We recommend dynamically generating the signature whenever you initialize the MCP client configuration with your Twilio MCP server. | ||
ℹ️ As the generated signature depends on the full Function endpoint that you are executing, and the URL includes the set of services (e.g. `/mcp?services=PhoneNumbers` vs `/mcp?services=Messaging`), you will need to generate a valid signature every time you update any part of the URL. We recommend dynamically generating the signature whenever you initialize the MCP client configuration with your Twilio MCP server. | ||
|
||
### npx with [`twilio-signature-cli`](https://www.npmjs.com/package/twilio-signature-cli) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had this under JavaScript because of |
||
|
||
#### JavaScript | ||
This CLI tool makes it easy to generate Twilio signatures for webhook validation without writing any code. It's perfect for testing and debugging Twilio webhook integrations, or for generating signatures in automated scripts. | ||
|
||
```shell | ||
npx twilio-signature-cli -t TWILIO_AUTH_TOKEN -u YOUR_FUNCTION_URL | ||
``` | ||
|
||
### JavaScript | ||
|
||
```javascript | ||
const crypto = require("crypto"); | ||
|
@@ -140,23 +141,15 @@ const dotenv = require("dotenv"); | |
|
||
dotenv.config(); | ||
|
||
const signature = | ||
const signature = | ||
createTwilioSignature( | ||
process.env.TWILIO_AUTH_TOKEN, | ||
`${process.env.TWILIO_DOMAIN_NAME}/mcp?services=...`, | ||
{} | ||
); | ||
``` | ||
|
||
#### npx with [`twilio-signature-cli`](https://www.npmjs.com/package/twilio-signature-cli) | ||
|
||
This CLI tool makes it easy to generate Twilio signatures for webhook validation without writing any code. It's perfect for testing and debugging Twilio webhook integrations, or for generating signatures in automated scripts. | ||
|
||
```shell | ||
npx twilio-signature-cli -t TWILIO_AUTH_TOKEN -u YOUR_FUNCTION_URL | ||
``` | ||
|
||
#### Python | ||
### Python | ||
|
||
```python | ||
import os | ||
|
@@ -171,7 +164,31 @@ validator = RequestValidator(auth_token) | |
signature = validator.compute_signature(url, {}) | ||
``` | ||
|
||
### Filtering tools by service | ||
## Integration with MCP clients | ||
|
||
* **URL**: `https://{functions-domain}.twil.io/mcp?services=` | ||
* **Authentication Header**: | ||
* Key: `x-twilio-signature` | ||
* Value: {Valid Twilio signature} | ||
|
||
### OpenAI Playground | ||
|
||
You can use [OpenAI Playground](https://platform.openai.com/playground) to try out the Twilio MCP server. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ... to try out |
||
|
||
1) Follow the instructions here to first deploy your MCP server. | ||
2) Visit [OpenAI Playground](https://platform.openai.com/playground) and click on `Create` in front of Tools. Then select `MCP Server` from the dropdown menu. Then select `Add new`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd make it |
||
3) Paste the URL of Twilio Functions MCP Server from step 1) in the URL `https://{functions-domain}.twil.io/mcp`. Include any services you want in the query parameter. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
4) For the `Authorization`, select `Custom headers`. For the header key, type in `x-twilio-signature`. | ||
5) For the header value, open your terminal and type `npx twilio-signature-cli -t AUTH_TOKEN -u https://{functions-domain}.twil.io/mcp`. Copy the output and paste it in the header value | ||
6) `Connect` | ||
|
||
_NOTE_: You can filter different Twilio Services by using the query param `services` in the URL. For example `https://{functions-domain}.twil.io/mcp?services=Studio&services=PhoneNumbers` would give you `Studio` and `Phone Numbers` services. If you change this URL, remember to re-run the `npx twilio-signature-cli ...` with the updated URL (including the query params) to generate a new signature. For a list of all available services, visit [Twilio Functions](https://github.com/twilio-labs/function-templates/tree/main/mcp-server#filtering-tools-by-service). | ||
|
||
### Javascript Code Sample | ||
|
||
You can visit and clone https://github.com/twilio-samples/openai-mcp-samples/ for examples of how to use the MCP Server with OpenAI. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
## Filtering tools by service | ||
|
||
Use the querystring parameter `?services=` to specify a set of tools based on the needs of your MCP client. Set multiple services by passing multiple `services` key/value pairs. | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo, but I'd recommend:
Generating a Twilio signature