@aigne/example-mcp-github 1.5.0 → 1.7.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/.env.local.example +1 -1
- package/README.md +12 -11
- package/index.ts +7 -12
- package/package.json +5 -5
- package/usages.ts +3 -6
package/.env.local.example
CHANGED
package/README.md
CHANGED
|
@@ -65,15 +65,17 @@ 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
|
-
- [OpenAI API key](https://platform.openai.com/api-keys)
|
|
68
|
+
- An [OpenAI API key](https://platform.openai.com/api-keys) for interacting with OpenAI's services
|
|
69
69
|
- [GitHub Personal Access Token](https://github.com/settings/tokens) with appropriate permissions
|
|
70
|
-
-
|
|
70
|
+
- Optional dependencies (if running the example from source code):
|
|
71
|
+
- [Bun](https://bun.sh) for running unit tests & examples
|
|
72
|
+
- [Pnpm](https://pnpm.io) for package management
|
|
71
73
|
|
|
72
|
-
##
|
|
74
|
+
## Quick Start (No Installation Required)
|
|
73
75
|
|
|
74
76
|
```bash
|
|
75
|
-
export OPENAI_API_KEY=YOUR_OPENAI_API_KEY #
|
|
76
|
-
export
|
|
77
|
+
export OPENAI_API_KEY=YOUR_OPENAI_API_KEY # Set your OpenAI API key
|
|
78
|
+
export GITHUB_TOKEN=YOUR_GITHUB_TOKEN # Set your GitHub token
|
|
77
79
|
|
|
78
80
|
npx -y @aigne/example-mcp-github # Run the example
|
|
79
81
|
```
|
|
@@ -99,8 +101,8 @@ pnpm install
|
|
|
99
101
|
Setup your API keys in the `.env.local` file:
|
|
100
102
|
|
|
101
103
|
```bash
|
|
102
|
-
OPENAI_API_KEY="" #
|
|
103
|
-
|
|
104
|
+
OPENAI_API_KEY="" # Set your OpenAI API key here
|
|
105
|
+
GITHUB_TOKEN="" # Set your GitHub Personal Access Token here
|
|
104
106
|
```
|
|
105
107
|
|
|
106
108
|
### Run the Example
|
|
@@ -119,9 +121,8 @@ The following example demonstrates how to use the GitHub MCP server to search fo
|
|
|
119
121
|
import { AIAgent, ExecutionEngine, MCPAgent } from "@aigne/core";
|
|
120
122
|
import { OpenAIChatModel } from "@aigne/core/models/openai-chat-model.js";
|
|
121
123
|
|
|
122
|
-
|
|
123
124
|
// Load environment variables
|
|
124
|
-
const { OPENAI_API_KEY,
|
|
125
|
+
const { OPENAI_API_KEY, GITHUB_TOKEN } = process.env;
|
|
125
126
|
|
|
126
127
|
// Initialize OpenAI model
|
|
127
128
|
const model = new OpenAIChatModel({
|
|
@@ -133,7 +134,7 @@ const githubMCPAgent = await MCPAgent.from({
|
|
|
133
134
|
command: "npx",
|
|
134
135
|
args: ["-y", "@modelcontextprotocol/server-github"],
|
|
135
136
|
env: {
|
|
136
|
-
|
|
137
|
+
GITHUB_TOKEN,
|
|
137
138
|
},
|
|
138
139
|
});
|
|
139
140
|
|
|
@@ -162,7 +163,7 @@ Always provide clear, concise responses with relevant information from GitHub.
|
|
|
162
163
|
// Example: Search for repositories
|
|
163
164
|
const result = await engine.call(
|
|
164
165
|
agent,
|
|
165
|
-
"Search for repositories related to 'modelcontextprotocol'"
|
|
166
|
+
"Search for repositories related to 'modelcontextprotocol'"
|
|
166
167
|
);
|
|
167
168
|
|
|
168
169
|
console.log(result);
|
package/index.ts
CHANGED
|
@@ -1,29 +1,24 @@
|
|
|
1
|
-
#!/usr/bin/env
|
|
1
|
+
#!/usr/bin/env bunwrapper
|
|
2
2
|
|
|
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.7.1",
|
|
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.5.1",
|
|
22
|
+
"@aigne/core": "^1.10.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
|
|