Build with Replit

Replit Agent can add Google Calendar and Microsoft Outlook to your app with Pyas. You connect the Pyas MCP server to Replit once. The agent then gets the code for each task from Pyas, and you store a key as a secret. The key stays on the server, and the code works with the sandbox's sample people before anyone connects a real calendar.

Add Pyas to Replit

Select Add Pyas to Replit (opens in a new tab). Replit opens your integration settings with Pyas filled in. Select Add to Replit, then sign in.

Or add it yourself:

  1. In Replit, open Settings, then Integrations.
  2. Under Your integrations, select Add custom, then Add personal MCP server.
  3. For Display name, enter Pyas. For MCP Server URL, enter https://mcp.pyas.io/sandbox.
  4. Select Test & save. Replit registers itself with Pyas and opens the sign-in. Sign in to Pyas, choose your app, and select Allow. See Sign in for what each permission allows.

The Pyas tools are then available to Replit Agent in all of your projects. When a tool needs your confirmation, Replit asks you before it runs.

Ask for what you want

Ask in plain words, for example:

Add a button that lets people connect their Google or Outlook calendar, and show their events for the next week.

The agent checks your setup with setup_status and gets the code for each task with get_recipe. It adds your app's address to the allowed origins with update_app, and creates a test key with get_test_key. You confirm the address in Pyas, from the link it gives you. Every response from Pyas ends with the next step, so the agent knows what to do next.

Store the key

Store the test key as a secret named PYAS_API_KEY:

  1. In your project, open Tools, then Secrets. Select New Secret, enter the name and the key, and select Add Secret.
  2. When you publish, add it again for the published app: open Publishing, then Adjust settings, then Production app secrets. Secrets in the editor don't carry over to the published app.

Your server reads the secret as process.env.PYAS_API_KEY, and it never reaches the browser. A test key works only in your app's sandbox.

What Replit Agent adds

The code runs in your app's Express server:

server/pyas.ts                         the Pyas client, and who is signed in
server/routes/pyas-connect-session.ts  creates a connect session for the button
server/routes/pyas-events.ts           the person's events for the next 7 days
server/routes/pyas-book.ts             books the first free 30 minutes tomorrow
client/ConnectCalendar.tsx             the "Connect an account" button

Each route file exports a router, which the agent mounts in your server with app.use(). Your pages call the routes with fetch, for example fetch('/api/pyas/events').

With a test key, the routes use the sandbox's sample person, so the events and booking work right away. The connect button shows a message from Pyas that connecting a real calendar requires a live key. This is expected.

Receive webhooks

Ask the agent to receive Pyas webhooks. It adds server/routes/pyas-webhooks.ts and mounts it before app.use(express.json()). The route verifies the signature of each delivery against the raw body, which no longer matches once the body is parsed.

The agent adds the endpoint to your sandbox with create_webhook, at your published address:

https://<your-app>.replit.app/api/pyas/webhooks

Use the published address, not the editor preview's, which can change. Store the signing secret that create_webhook returns as a secret named PYAS_WEBHOOK_SECRET, in the editor and in the published app's secrets. See Webhooks for the events Pyas sends.

Go live

  1. Make currentUserId() in server/pyas.ts return the signed-in person's ID from your app's sign-in. Until then, the routes respond with 401 and the code SIGN_IN_REQUIRED to every request made with a live key, so people's calendars never mix.
  2. In the Pyas dashboard, choose a plan and create a live key. Plans, payment and live keys are always done by you, in the dashboard.
  3. Replace the PYAS_API_KEY secret with the live key, in the editor and in the published app's secrets.
  4. Add your published address to the app's allowed origins, and add a live webhook endpoint in the dashboard.