Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,54 @@ import { createRecord, updateRecord } from "@amp-labs/ai/mastra";
const tools = [createRecord, updateRecord];
```

### Testing

The `test` directory contains end-to-end tests for the AI SDK.

#### Running the Simple Test

**Prerequisites:**
- OpenAI API key (required for AI model)
- Ampersand API credentials

1. Configure environment variables in `test/.env`:
```bash
OPENAI_API_KEY=your_openai_api_key_here
AMPERSAND_API_KEY=your_ampersand_api_key_here
AMPERSAND_PROJECT_ID=your_project_id_here
AMPERSAND_GROUP_REF=your_group_ref_here
```

2. Run the test:
```bash
# From the root directory
pnpm --filter ai-e2e-test test:simple

# Or from the test directory
cd test
pnpm test:simple
```

The simple test demonstrates how to use the `checkConnection` tool with the Vercel AI SDK to verify Salesforce connections.

#### Testing Local Changes

The test uses your **local SDK build** via pnpm workspace linking. To test modifications to the SDK:

1. Make changes to SDK source files in `sdk/lib/`

2. Rebuild the SDK:
```bash
pnpm --filter @amp-labs/ai build
```

3. Re-run the test to verify your changes:
```bash
pnpm --filter ai-e2e-test test:simple
```

The test will use the freshly built SDK from `sdk/dist/`, allowing you to iterate quickly on SDK changes.

## Ampersand MCP Server

Connect your agents to the 150+ connectors we offer at Ampersand via this multi-tenant MCP server. We expose the primitives we offer on the Ampersand platform as native tools here.
Expand Down
147 changes: 147 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
packages:
- 'mcp-server'
- 'sdk'
- 'examples'
- 'examples'
- 'test'
32 changes: 28 additions & 4 deletions sdk/lib/adapters/aisdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,9 @@ export const checkInstallation = tool({
/**
* Initiates OAuth flow for a provider using Vercel AI SDK.
* @param provider - The provider to authenticate with
* @param groupRef - Optional group reference
* @param consumerRef - Optional consumer reference
* @param groupRef - The group reference for identifying the group of users
* @param consumerRef - The consumer reference for identifying the user
* @param providerWorkspaceRef - Optional provider workspace identifier (e.g. Salesforce subdomain)
* @returns Object containing the OAuth URL for authentication
*/
export const startOAuth = tool({
Expand All @@ -185,15 +186,16 @@ export const startOAuth = tool({
execute: async (
params: StartOAuthInputType,
): Promise<StartOAuthOutputType> => {
const { provider, groupRef, consumerRef } = params;
const { provider, groupRef, consumerRef, providerWorkspaceRef } = params;
const projectId = process.env.AMPERSAND_PROJECT_ID || '';
const apiKey = process.env.AMPERSAND_API_KEY || '';
const url = await getOAuthURL({
provider,
groupRef: process.env.AMPERSAND_GROUP_REF || groupRef,
groupRef,
consumerRef,
projectId,
apiKey,
providerWorkspaceRef,
});
return { url };
},
Expand Down Expand Up @@ -270,3 +272,25 @@ export const sendReadRequest = tool({
});
},
});

// Re-export schemas for testing and validation
export {
createActionSchema,
updateActionSchema,
checkConnectionInputSchema,
checkConnectionOutputSchema,
createInstallationInputSchema,
createInstallationOutputSchema,
checkInstallationInputSchema,
checkInstallationOutputSchema,
startOAuthInputSchema,
startOAuthOutputSchema,
sendRequestInputSchema,
sendRequestOutputSchema,
sendReadRequestInputSchema,
associationsSchema,
providerSchema,
endpointSchema,
installationIdSchema,
writeOutputSchema,
} from './ampersand/schemas';
Loading
Loading