@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.
@@ -4,4 +4,4 @@ DEBUG=aigne:mcp
4
4
 
5
5
  OPENAI_API_KEY="" # Your OpenAI API key
6
6
 
7
- GITHUB_PERSONAL_ACCESS_TOKEN="" # Your GitHub Personal Access Token
7
+ GITHUB_TOKEN="" # Your GitHub Personal Access Token
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) used to interact with OpenAI API
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
- - [Pnpm](https://pnpm.io) [Optional] if you want to run the example from source code
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
- ## Try without Installation
74
+ ## Quick Start (No Installation Required)
73
75
 
74
76
  ```bash
75
- export OPENAI_API_KEY=YOUR_OPENAI_API_KEY # Setup your OpenAI API key
76
- export GITHUB_PERSONAL_ACCESS_TOKEN=YOUR_GITHUB_TOKEN # Setup your GitHub token
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="" # Your OpenAI API key
103
- GITHUB_PERSONAL_ACCESS_TOKEN="" # Your GitHub Personal Access Token
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, GITHUB_PERSONAL_ACCESS_TOKEN } = process.env;
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
- GITHUB_PERSONAL_ACCESS_TOKEN,
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 npx -y bun
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 { OpenAIChatModel } from "@aigne/core/models/openai-chat-model.js";
6
+ import { loadModel } from "@aigne/core/loader/index.js";
7
7
  import { logger } from "@aigne/core/utils/logger.js";
8
8
 
9
- const { OPENAI_API_KEY, GITHUB_PERSONAL_ACCESS_TOKEN } = process.env;
10
- assert(OPENAI_API_KEY, "Please set the OPENAI_API_KEY environment variable");
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 = new OpenAIChatModel({
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
- GITHUB_PERSONAL_ACCESS_TOKEN,
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.5.0",
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.93.0",
19
+ "openai": "^4.94.0",
20
20
  "zod": "^3.24.2",
21
- "@aigne/core": "^1.7.0",
22
- "@aigne/cli": "^1.2.0"
21
+ "@aigne/cli": "^1.5.1",
22
+ "@aigne/core": "^1.10.0"
23
23
  },
24
24
  "scripts": {
25
- "start": "npx -y bun run index.ts",
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, GITHUB_PERSONAL_ACCESS_TOKEN } = process.env;
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
- GITHUB_PERSONAL_ACCESS_TOKEN,
17
+ GITHUB_TOKEN,
21
18
  },
22
19
  });
23
20