Skip to content

Commit 05012a0

Browse files
authored
Merge pull request #47 from VoltAgent/blog/data-aware-chatbot-voltagent-peaka
feat: add blog '2025-04-26-peaka-mcp-voltagent'
2 parents b42b85b + 97e355d commit 05012a0

11 files changed

Lines changed: 395 additions & 39 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
OPENAI_API_KEY=your_openai_api_key
2+
PEAKA_API_KEY=your_peaka_api_key

examples/with-peaka-mcp/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
dist
3+
.DS_Store

examples/with-peaka-mcp/README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<div align="center">
2+
<a href="https://voltagent.dev/">
3+
<img width="1800" alt="435380213-b6253409-8741-462b-a346-834cd18565a9" src="https://github.com/user-attachments/assets/452a03e7-eeda-4394-9ee7-0ffbcf37245c" />
4+
</a>
5+
6+
<br/>
7+
<br/>
8+
9+
<div align="center">
10+
<a href="https://voltagent.dev">Home Page</a> |
11+
<a href="https://voltagent.dev/docs/">Documentation</a> |
12+
<a href="https://github.com/voltagent/voltagent/tree/main/examples">Examples</a> |
13+
<a href="https://s.voltagent.dev/discord">Discord</a> |
14+
<a href="https://voltagent.dev/blog/">Blog</a>
15+
</div>
16+
</div>
17+
18+
<br/>
19+
20+
<div align="center">
21+
<strong>VoltAgent is an open source TypeScript framework for building and orchestrating AI agents.</strong><br>
22+
Escape the limitations of no-code builders and the complexity of starting from scratch.
23+
<br />
24+
<br />
25+
</div>
26+
27+
<div align="center">
28+
29+
[![npm version](https://img.shields.io/npm/v/@voltagent/core.svg)](https://www.npmjs.com/package/@voltagent/core)
30+
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.0-4baaaa.svg)](CODE_OF_CONDUCT.md)
31+
[![Discord](https://img.shields.io/discord/1361559153780195478.svg?label=&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://s.voltagent.dev/discord)
32+
[![Twitter Follow](https://img.shields.io/twitter/follow/voltagent_dev?style=social)](https://twitter.com/voltagent_dev)
33+
34+
</div>
35+
36+
<br/>
37+
38+
<div align="center">
39+
<a href="https://voltagent.dev/">
40+
<img width="896" alt="Screenshot 2025-04-20 at 22 44 38" src="https://github.com/user-attachments/assets/f0627868-6153-4f63-ba7f-bdfcc5dd603d" />
41+
</a>
42+
43+
</div>
44+
45+
## VoltAgent: Build AI Agents Fast and Flexibly
46+
47+
VoltAgent is an open-source TypeScript framework for creating and managing AI agents. It provides modular components to build, customize, and scale agents with ease. From connecting to APIs and memory management to supporting multiple LLMs, VoltAgent simplifies the process of creating sophisticated AI systems. It enables fast development, maintains clean code, and offers flexibility to switch between models and tools without vendor lock-in.
48+
49+
## Try Example
50+
51+
```bash
52+
npm create voltagent-app@latest -- --example with-peaka-mcp
53+
```
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "voltagent-example-with-peaka-mcp",
3+
"private": true,
4+
"keywords": [
5+
"voltagent",
6+
"ai",
7+
"agent"
8+
],
9+
"license": "MIT",
10+
"author": "",
11+
"type": "module",
12+
"scripts": {
13+
"build": "tsc",
14+
"dev": "tsx watch --env-file=.env ./src -- --trace-warnings",
15+
"start": "node dist/index.js",
16+
"volt": "volt"
17+
},
18+
"dependencies": {
19+
"@ai-sdk/openai": "^1.3.10",
20+
"@voltagent/cli": "^0.1.3",
21+
"@voltagent/core": "^0.1.6",
22+
"@voltagent/vercel-ai": "^0.1.3",
23+
"zod": "^3.24.2"
24+
},
25+
"devDependencies": {
26+
"@types/node": "^22.13.5",
27+
"tsx": "^4.19.3",
28+
"typescript": "^5.8.2"
29+
}
30+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { VoltAgent, Agent, MCPConfiguration } from "@voltagent/core";
2+
import { VercelAIProvider } from "@voltagent/vercel-ai";
3+
4+
import { openai } from "@ai-sdk/openai";
5+
6+
const mcp = new MCPConfiguration({
7+
id: "peaka-mcp",
8+
servers: {
9+
peaka: {
10+
type: "stdio",
11+
command: "npx",
12+
args: ["-y", "@peaka/mcp-server-peaka@latest"],
13+
env: { PEAKA_API_KEY: process.env.PEAKA_API_KEY || "" },
14+
},
15+
},
16+
});
17+
18+
(async () => {
19+
const tools = await mcp.getTools();
20+
const agent = new Agent({
21+
name: "Peaka Data Assistant",
22+
description: "An assistant that can query Peaka's sample data.",
23+
llm: new VercelAIProvider(),
24+
model: openai("gpt-4o-mini"),
25+
tools: [...tools],
26+
markdown: true,
27+
});
28+
29+
new VoltAgent({
30+
agents: {
31+
agent,
32+
},
33+
});
34+
})();
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES2022",
4+
"module": "NodeNext",
5+
"moduleResolution": "NodeNext",
6+
"esModuleInterop": true,
7+
"forceConsistentCasingInFileNames": true,
8+
"strict": true,
9+
"outDir": "dist",
10+
"skipLibCheck": true
11+
},
12+
"include": ["src"],
13+
"exclude": ["node_modules", "dist"]
14+
}

packages/google-ai/src/index.spec.ts

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -152,37 +152,38 @@ describe("GoogleGenAIProvider", () => {
152152
yield { text: "Hello", responseId: "chunk1" };
153153
yield { text: ", ", responseId: "chunk2" };
154154
yield { text: "world!", responseId: "chunk3", candidates: [{ finishReason: "STOP" }] };
155-
yield {
156-
text: "", responseId: "final",
155+
yield {
156+
text: "",
157+
responseId: "final",
157158
usageMetadata: {
158159
promptTokenCount: 5,
159160
candidatesTokenCount: 15,
160-
totalTokenCount: 20
161-
}
161+
totalTokenCount: 20,
162+
},
162163
};
163164
}
164165

165166
const mockGenerateContentStream = jest.fn().mockResolvedValue(mockGenerator());
166-
167+
167168
const provider = new GoogleGenAIProvider({ apiKey: "test-api-key" });
168169
(provider as any).ai.models.generateContentStream = mockGenerateContentStream;
169-
170+
170171
const onChunkMock = jest.fn();
171172
const onStepFinishMock = jest.fn();
172-
173+
173174
const result = await provider.streamText({
174175
messages: [{ role: "user", content: "Hello!" }],
175176
model: "gemini-2.0-flash-001",
176177
onChunk: onChunkMock,
177-
onStepFinish: onStepFinishMock
178+
onStepFinish: onStepFinishMock,
178179
});
179-
180+
180181
expect(result.textStream).toBeInstanceOf(ReadableStream);
181-
182+
182183
// Read all chunks from the stream
183184
const reader = result.textStream.getReader();
184185
const chunks = [];
185-
186+
186187
let done = false;
187188
while (!done) {
188189
const { value, done: isDone } = await reader.read();
@@ -192,9 +193,9 @@ describe("GoogleGenAIProvider", () => {
192193
chunks.push(value);
193194
}
194195
}
195-
196+
196197
expect(chunks).toEqual(["Hello", ", ", "world!"]);
197-
198+
198199
expect(onChunkMock).toHaveBeenCalledTimes(3);
199200
expect(onStepFinishMock).toHaveBeenCalledTimes(1);
200201
expect(onStepFinishMock).toHaveBeenCalledWith({
@@ -205,8 +206,8 @@ describe("GoogleGenAIProvider", () => {
205206
usage: {
206207
promptTokens: 5,
207208
completionTokens: 15,
208-
totalTokens: 20
209-
}
209+
totalTokens: 20,
210+
},
210211
});
211212
});
212213
});

pnpm-lock.yaml

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)