@aigne/example-mcp-github 1.5.0 → 1.6.0
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/.env.local.example +1 -1
- package/README.md +6 -6
- package/index.ts +6 -11
- package/package.json +5 -5
- package/usages.ts +3 -6
package/.env.local.example
CHANGED
package/README.md
CHANGED
|
@@ -65,6 +65,7 @@ AI ->> User: Here's the README content: ...
|
|
|
65
65
|
## Prerequisites
|
|
66
66
|
|
|
67
67
|
- [Node.js](https://nodejs.org) and npm installed on your machine
|
|
68
|
+
- [Bun](https://bun.sh) installed on your machine
|
|
68
69
|
- [OpenAI API key](https://platform.openai.com/api-keys) used to interact with OpenAI API
|
|
69
70
|
- [GitHub Personal Access Token](https://github.com/settings/tokens) with appropriate permissions
|
|
70
71
|
- [Pnpm](https://pnpm.io) [Optional] if you want to run the example from source code
|
|
@@ -73,7 +74,7 @@ AI ->> User: Here's the README content: ...
|
|
|
73
74
|
|
|
74
75
|
```bash
|
|
75
76
|
export OPENAI_API_KEY=YOUR_OPENAI_API_KEY # Setup your OpenAI API key
|
|
76
|
-
export
|
|
77
|
+
export GITHUB_TOKEN=YOUR_GITHUB_TOKEN # Setup your GitHub token
|
|
77
78
|
|
|
78
79
|
npx -y @aigne/example-mcp-github # Run the example
|
|
79
80
|
```
|
|
@@ -100,7 +101,7 @@ Setup your API keys in the `.env.local` file:
|
|
|
100
101
|
|
|
101
102
|
```bash
|
|
102
103
|
OPENAI_API_KEY="" # Your OpenAI API key
|
|
103
|
-
|
|
104
|
+
GITHUB_TOKEN="" # Your GitHub Personal Access Token
|
|
104
105
|
```
|
|
105
106
|
|
|
106
107
|
### Run the Example
|
|
@@ -119,9 +120,8 @@ The following example demonstrates how to use the GitHub MCP server to search fo
|
|
|
119
120
|
import { AIAgent, ExecutionEngine, MCPAgent } from "@aigne/core";
|
|
120
121
|
import { OpenAIChatModel } from "@aigne/core/models/openai-chat-model.js";
|
|
121
122
|
|
|
122
|
-
|
|
123
123
|
// Load environment variables
|
|
124
|
-
const { OPENAI_API_KEY,
|
|
124
|
+
const { OPENAI_API_KEY, GITHUB_TOKEN } = process.env;
|
|
125
125
|
|
|
126
126
|
// Initialize OpenAI model
|
|
127
127
|
const model = new OpenAIChatModel({
|
|
@@ -133,7 +133,7 @@ const githubMCPAgent = await MCPAgent.from({
|
|
|
133
133
|
command: "npx",
|
|
134
134
|
args: ["-y", "@modelcontextprotocol/server-github"],
|
|
135
135
|
env: {
|
|
136
|
-
|
|
136
|
+
GITHUB_TOKEN,
|
|
137
137
|
},
|
|
138
138
|
});
|
|
139
139
|
|
|
@@ -162,7 +162,7 @@ Always provide clear, concise responses with relevant information from GitHub.
|
|
|
162
162
|
// Example: Search for repositories
|
|
163
163
|
const result = await engine.call(
|
|
164
164
|
agent,
|
|
165
|
-
"Search for repositories related to 'modelcontextprotocol'"
|
|
165
|
+
"Search for repositories related to 'modelcontextprotocol'"
|
|
166
166
|
);
|
|
167
167
|
|
|
168
168
|
console.log(result);
|
package/index.ts
CHANGED
|
@@ -3,27 +3,22 @@
|
|
|
3
3
|
import assert from "node:assert";
|
|
4
4
|
import { runChatLoopInTerminal } from "@aigne/cli/utils/run-chat-loop.js";
|
|
5
5
|
import { AIAgent, ExecutionEngine, MCPAgent } from "@aigne/core";
|
|
6
|
-
import {
|
|
6
|
+
import { loadModel } from "@aigne/core/loader/index.js";
|
|
7
7
|
import { logger } from "@aigne/core/utils/logger.js";
|
|
8
8
|
|
|
9
|
-
const {
|
|
10
|
-
|
|
11
|
-
assert(
|
|
12
|
-
GITHUB_PERSONAL_ACCESS_TOKEN,
|
|
13
|
-
"Please set the GITHUB_PERSONAL_ACCESS_TOKEN environment variable",
|
|
14
|
-
);
|
|
9
|
+
const { GITHUB_TOKEN } = process.env;
|
|
10
|
+
|
|
11
|
+
assert(GITHUB_TOKEN, "Please set the GITHUB_TOKEN environment variable");
|
|
15
12
|
|
|
16
13
|
logger.enable(`aigne:mcp,${process.env.DEBUG}`);
|
|
17
14
|
|
|
18
|
-
const model =
|
|
19
|
-
apiKey: OPENAI_API_KEY,
|
|
20
|
-
});
|
|
15
|
+
const model = await loadModel();
|
|
21
16
|
|
|
22
17
|
const github = await MCPAgent.from({
|
|
23
18
|
command: "npx",
|
|
24
19
|
args: ["-y", "@modelcontextprotocol/server-github"],
|
|
25
20
|
env: {
|
|
26
|
-
|
|
21
|
+
GITHUB_TOKEN,
|
|
27
22
|
},
|
|
28
23
|
});
|
|
29
24
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aigne/example-mcp-github",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "A demonstration of using AIGNE Framework and GitHub MCP Server to interact with GitHub repositories",
|
|
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-github",
|
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
"README.md"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"openai": "^4.
|
|
19
|
+
"openai": "^4.94.0",
|
|
20
20
|
"zod": "^3.24.2",
|
|
21
|
-
"@aigne/
|
|
22
|
-
"@aigne/
|
|
21
|
+
"@aigne/cli": "^1.3.0",
|
|
22
|
+
"@aigne/core": "^1.8.0"
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
|
-
"start": "
|
|
25
|
+
"start": "bun run index.ts",
|
|
26
26
|
"lint": "tsc --noEmit"
|
|
27
27
|
}
|
|
28
28
|
}
|
package/usages.ts
CHANGED
|
@@ -2,12 +2,9 @@ import assert from "node:assert";
|
|
|
2
2
|
import { AIAgent, ExecutionEngine, MCPAgent } from "@aigne/core";
|
|
3
3
|
import { OpenAIChatModel } from "@aigne/core/models/openai-chat-model.js";
|
|
4
4
|
|
|
5
|
-
const { OPENAI_API_KEY,
|
|
5
|
+
const { OPENAI_API_KEY, GITHUB_TOKEN } = process.env;
|
|
6
6
|
assert(OPENAI_API_KEY, "Please set the OPENAI_API_KEY environment variable");
|
|
7
|
-
assert(
|
|
8
|
-
GITHUB_PERSONAL_ACCESS_TOKEN,
|
|
9
|
-
"Please set the GITHUB_PERSONAL_ACCESS_TOKEN environment variable",
|
|
10
|
-
);
|
|
7
|
+
assert(GITHUB_TOKEN, "Please set the GITHUB_TOKEN environment variable");
|
|
11
8
|
|
|
12
9
|
const model = new OpenAIChatModel({
|
|
13
10
|
apiKey: OPENAI_API_KEY,
|
|
@@ -17,7 +14,7 @@ const githubMCPAgent = await MCPAgent.from({
|
|
|
17
14
|
command: "npx",
|
|
18
15
|
args: ["-y", "@modelcontextprotocol/server-github"],
|
|
19
16
|
env: {
|
|
20
|
-
|
|
17
|
+
GITHUB_TOKEN,
|
|
21
18
|
},
|
|
22
19
|
});
|
|
23
20
|
|