import { experimental_createMCPClient } from '@ai-sdk/mcp';
import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
const [githubClient, linearClient] = await Promise.all([
experimental_createMCPClient({
transport: {
type: 'http',
url: 'https://mcp.runlayer.com/github-a1b2c3/mcp',
headers: { 'x-runlayer-api-key': 'your-api-key' }
}
}),
experimental_createMCPClient({
transport: {
type: 'http',
url: 'https://mcp.runlayer.com/linear-d4e5f6/mcp',
headers: { 'x-runlayer-api-key': 'your-api-key' }
}
})
]);
try {
const [githubTools, linearTools] = await Promise.all([
githubClient.tools(),
linearClient.tools()
]);
const tools = { ...githubTools, ...linearTools };
const result = await generateText({
model: openai('gpt-4o'),
tools,
prompt: 'Create a GitHub issue and a Linear ticket for the bug report'
});
console.log(result.text);
} finally {
await Promise.all([
githubClient.close(),
linearClient.close()
]);
}