@aigne/example-mcp-sqlite 1.11.1 → 1.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -3
- package/index.ts +32 -37
- package/package.json +6 -6
- package/usages.ts +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Sqlite MCP Server Demo
|
|
2
2
|
|
|
3
|
-
This is a demonstration of using [AIGNE Framework](https://github.com/AIGNE-io/aigne-framework) and [MCP Server SQlite](https://github.com/modelcontextprotocol/servers/tree/main/src/sqlite) to interact with SQLite databases.
|
|
3
|
+
This is a demonstration of using [AIGNE Framework](https://github.com/AIGNE-io/aigne-framework) and [MCP Server SQlite](https://github.com/modelcontextprotocol/servers/tree/main/src/sqlite) to interact with SQLite databases. The example now supports both one-shot and interactive chat modes, along with customizable model settings and pipeline input/output.
|
|
4
4
|
|
|
5
5
|
```mermaid
|
|
6
6
|
flowchart LR
|
|
@@ -71,7 +71,14 @@ AI ->> User: There are 10 products in the database.
|
|
|
71
71
|
```bash
|
|
72
72
|
export OPENAI_API_KEY=YOUR_OPENAI_API_KEY # Set your OpenAI API key
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
# Run in one-shot mode (default)
|
|
75
|
+
npx -y @aigne/example-mcp-sqlite
|
|
76
|
+
|
|
77
|
+
# Run in interactive chat mode
|
|
78
|
+
npx -y @aigne/example-mcp-sqlite --chat
|
|
79
|
+
|
|
80
|
+
# Use pipeline input
|
|
81
|
+
echo "create a product table with columns name description and createdAt" | npx -y @aigne/example-mcp-sqlite
|
|
75
82
|
```
|
|
76
83
|
|
|
77
84
|
## Installation
|
|
@@ -101,7 +108,41 @@ OPENAI_API_KEY="" # Set your OpenAI API key here
|
|
|
101
108
|
### Run the Example
|
|
102
109
|
|
|
103
110
|
```bash
|
|
104
|
-
pnpm start
|
|
111
|
+
pnpm start # Run in one-shot mode (default)
|
|
112
|
+
|
|
113
|
+
# Run in interactive chat mode
|
|
114
|
+
pnpm start -- --chat
|
|
115
|
+
|
|
116
|
+
# Use pipeline input
|
|
117
|
+
echo "create a product table with columns name description and createdAt" | pnpm start
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Run Options
|
|
121
|
+
|
|
122
|
+
The example supports the following command-line parameters:
|
|
123
|
+
|
|
124
|
+
| Parameter | Description | Default |
|
|
125
|
+
|-----------|-------------|---------|
|
|
126
|
+
| `--chat` | Run in interactive chat mode | Disabled (one-shot mode) |
|
|
127
|
+
| `--model <provider[:model]>` | AI model to use in format 'provider[:model]' where model is optional. Examples: 'openai' or 'openai:gpt-4o-mini' | openai |
|
|
128
|
+
| `--temperature <value>` | Temperature for model generation | Provider default |
|
|
129
|
+
| `--top-p <value>` | Top-p sampling value | Provider default |
|
|
130
|
+
| `--presence-penalty <value>` | Presence penalty value | Provider default |
|
|
131
|
+
| `--frequency-penalty <value>` | Frequency penalty value | Provider default |
|
|
132
|
+
| `--log-level <level>` | Set logging level (ERROR, WARN, INFO, DEBUG, TRACE) | INFO |
|
|
133
|
+
| `--input`, `-i <input>` | Specify input directly | None |
|
|
134
|
+
|
|
135
|
+
#### Examples
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
# Run in chat mode (interactive)
|
|
139
|
+
pnpm start -- --chat
|
|
140
|
+
|
|
141
|
+
# Set logging level
|
|
142
|
+
pnpm start -- --log-level DEBUG
|
|
143
|
+
|
|
144
|
+
# Use pipeline input
|
|
145
|
+
echo "how many products?" | pnpm start
|
|
105
146
|
```
|
|
106
147
|
|
|
107
148
|
## Example
|
package/index.ts
CHANGED
|
@@ -1,42 +1,37 @@
|
|
|
1
1
|
#!/usr/bin/env bunwrapper
|
|
2
2
|
|
|
3
3
|
import { join } from "node:path";
|
|
4
|
-
import {
|
|
5
|
-
import { AIAgent,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const userAgent = aigne.invoke(agent);
|
|
37
|
-
|
|
38
|
-
await runChatLoopInTerminal(userAgent, {
|
|
39
|
-
initialCall: {},
|
|
40
|
-
});
|
|
4
|
+
import { runWithAIGNE } from "@aigne/cli/utils/run-with-aigne.js";
|
|
5
|
+
import { AIAgent, MCPAgent, PromptBuilder } from "@aigne/core";
|
|
6
|
+
|
|
7
|
+
await runWithAIGNE(
|
|
8
|
+
async () => {
|
|
9
|
+
const sqlite = await MCPAgent.from({
|
|
10
|
+
command: "uvx",
|
|
11
|
+
args: [
|
|
12
|
+
"-q",
|
|
13
|
+
"mcp-server-sqlite",
|
|
14
|
+
"--db-path",
|
|
15
|
+
join(process.cwd(), "aigne-example-sqlite-mcp-server.db"),
|
|
16
|
+
],
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const prompt = await sqlite.prompts["mcp-demo"]?.invoke({ topic: "product service" });
|
|
20
|
+
if (!prompt) throw new Error("Prompt mcp-demo not found");
|
|
21
|
+
|
|
22
|
+
const agent = AIAgent.from({
|
|
23
|
+
instructions: PromptBuilder.from(prompt),
|
|
24
|
+
skills: [sqlite],
|
|
25
|
+
memory: true,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
return agent;
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
chatLoopOptions: {
|
|
32
|
+
initialCall: {},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
);
|
|
41
36
|
|
|
42
37
|
process.exit(0);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aigne/example-mcp-sqlite",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.1",
|
|
4
4
|
"description": "A demonstration of using AIGNE Framework and Sqlite MCP Server to interact with a SQLite database",
|
|
5
5
|
"author": "Arcblock <blocklet@arcblock.io> https://github.com/blocklet",
|
|
6
6
|
"homepage": "https://github.com/AIGNE-io/aigne-framework/tree/main/examples/mcp-sqlite",
|
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
"README.md"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"@aigne/
|
|
22
|
-
"@aigne/core": "^1.15.0"
|
|
19
|
+
"@aigne/cli": "^1.10.1",
|
|
20
|
+
"@aigne/openai": "^0.2.0",
|
|
21
|
+
"@aigne/core": "^1.17.0"
|
|
23
22
|
},
|
|
24
23
|
"devDependencies": {
|
|
25
|
-
"@
|
|
24
|
+
"@types/bun": "^1.2.9",
|
|
25
|
+
"@aigne/test-utils": "^0.3.1"
|
|
26
26
|
},
|
|
27
27
|
"scripts": {
|
|
28
28
|
"start": "bun run index.ts",
|
package/usages.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import assert from "node:assert";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { AIAgent, AIGNE, MCPAgent } from "@aigne/core";
|
|
4
|
-
import { OpenAIChatModel } from "@aigne/
|
|
4
|
+
import { OpenAIChatModel } from "@aigne/openai";
|
|
5
5
|
|
|
6
6
|
const { OPENAI_API_KEY } = process.env;
|
|
7
7
|
assert(OPENAI_API_KEY, "Please set the OPENAI_API_KEY environment variable");
|