@aigne/example-mcp-github 1.7.2 → 1.9.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/LICENSE +93 -0
- package/README.md +7 -7
- package/index.test.ts +11 -0
- package/index.ts +4 -4
- package/package.json +9 -5
- package/usages.ts +7 -7
package/LICENSE
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Elastic License 2.0
|
|
2
|
+
|
|
3
|
+
URL: https://www.elastic.co/licensing/elastic-license
|
|
4
|
+
|
|
5
|
+
## Acceptance
|
|
6
|
+
|
|
7
|
+
By using the software, you agree to all of the terms and conditions below.
|
|
8
|
+
|
|
9
|
+
## Copyright License
|
|
10
|
+
|
|
11
|
+
The licensor grants you a non-exclusive, royalty-free, worldwide,
|
|
12
|
+
non-sublicensable, non-transferable license to use, copy, distribute, make
|
|
13
|
+
available, and prepare derivative works of the software, in each case subject to
|
|
14
|
+
the limitations and conditions below.
|
|
15
|
+
|
|
16
|
+
## Limitations
|
|
17
|
+
|
|
18
|
+
You may not provide the software to third parties as a hosted or managed
|
|
19
|
+
service, where the service provides users with access to any substantial set of
|
|
20
|
+
the features or functionality of the software.
|
|
21
|
+
|
|
22
|
+
You may not move, change, disable, or circumvent the license key functionality
|
|
23
|
+
in the software, and you may not remove or obscure any functionality in the
|
|
24
|
+
software that is protected by the license key.
|
|
25
|
+
|
|
26
|
+
You may not alter, remove, or obscure any licensing, copyright, or other notices
|
|
27
|
+
of the licensor in the software. Any use of the licensor’s trademarks is subject
|
|
28
|
+
to applicable law.
|
|
29
|
+
|
|
30
|
+
## Patents
|
|
31
|
+
|
|
32
|
+
The licensor grants you a license, under any patent claims the licensor can
|
|
33
|
+
license, or becomes able to license, to make, have made, use, sell, offer for
|
|
34
|
+
sale, import and have imported the software, in each case subject to the
|
|
35
|
+
limitations and conditions in this license. This license does not cover any
|
|
36
|
+
patent claims that you cause to be infringed by modifications or additions to
|
|
37
|
+
the software. If you or your company make any written claim that the software
|
|
38
|
+
infringes or contributes to infringement of any patent, your patent license for
|
|
39
|
+
the software granted under these terms ends immediately. If your company makes
|
|
40
|
+
such a claim, your patent license ends immediately for work on behalf of your
|
|
41
|
+
company.
|
|
42
|
+
|
|
43
|
+
## Notices
|
|
44
|
+
|
|
45
|
+
You must ensure that anyone who gets a copy of any part of the software from you
|
|
46
|
+
also gets a copy of these terms.
|
|
47
|
+
|
|
48
|
+
If you modify the software, you must include in any modified copies of the
|
|
49
|
+
software prominent notices stating that you have modified the software.
|
|
50
|
+
|
|
51
|
+
## No Other Rights
|
|
52
|
+
|
|
53
|
+
These terms do not imply any licenses other than those expressly granted in
|
|
54
|
+
these terms.
|
|
55
|
+
|
|
56
|
+
## Termination
|
|
57
|
+
|
|
58
|
+
If you use the software in violation of these terms, such use is not licensed,
|
|
59
|
+
and your licenses will automatically terminate. If the licensor provides you
|
|
60
|
+
with a notice of your violation, and you cease all violation of this license no
|
|
61
|
+
later than 30 days after you receive that notice, your licenses will be
|
|
62
|
+
reinstated retroactively. However, if you violate these terms after such
|
|
63
|
+
reinstatement, any additional violation of these terms will cause your licenses
|
|
64
|
+
to terminate automatically and permanently.
|
|
65
|
+
|
|
66
|
+
## No Liability
|
|
67
|
+
|
|
68
|
+
*As far as the law allows, the software comes as is, without any warranty or
|
|
69
|
+
condition, and the licensor will not be liable to you for any damages arising
|
|
70
|
+
out of these terms or the use or nature of the software, under any kind of
|
|
71
|
+
legal claim.*
|
|
72
|
+
|
|
73
|
+
## Definitions
|
|
74
|
+
|
|
75
|
+
The **licensor** is the entity offering these terms, and the **software** is the
|
|
76
|
+
software the licensor makes available under these terms, including any portion
|
|
77
|
+
of it.
|
|
78
|
+
|
|
79
|
+
**you** refers to the individual or entity agreeing to these terms.
|
|
80
|
+
|
|
81
|
+
**your company** is any legal entity, sole proprietorship, or other kind of
|
|
82
|
+
organization that you work for, plus all organizations that have control over,
|
|
83
|
+
are under the control of, or are under common control with that
|
|
84
|
+
organization. **control** means ownership of substantially all the assets of an
|
|
85
|
+
entity, or the power to direct its management and policies by vote, contract, or
|
|
86
|
+
otherwise. Control can be direct or indirect.
|
|
87
|
+
|
|
88
|
+
**your licenses** are all the licenses granted to you for the software under
|
|
89
|
+
these terms.
|
|
90
|
+
|
|
91
|
+
**use** means anything you do with the software requiring one of your licenses.
|
|
92
|
+
|
|
93
|
+
**trademark** means trademarks, service marks, and similar rights.
|
package/README.md
CHANGED
|
@@ -118,7 +118,7 @@ pnpm example # Run predefined examples
|
|
|
118
118
|
The following example demonstrates how to use the GitHub MCP server to search for repositories:
|
|
119
119
|
|
|
120
120
|
```typescript
|
|
121
|
-
import { AIAgent,
|
|
121
|
+
import { AIAgent, AIGNE, MCPAgent } from "@aigne/core";
|
|
122
122
|
import { OpenAIChatModel } from "@aigne/core/models/openai-chat-model.js";
|
|
123
123
|
|
|
124
124
|
// Load environment variables
|
|
@@ -138,10 +138,10 @@ const githubMCPAgent = await MCPAgent.from({
|
|
|
138
138
|
},
|
|
139
139
|
});
|
|
140
140
|
|
|
141
|
-
// Create
|
|
142
|
-
const
|
|
141
|
+
// Create AIGNE
|
|
142
|
+
const aigne = new AIGNE({
|
|
143
143
|
model,
|
|
144
|
-
|
|
144
|
+
skills: [githubMCPAgent],
|
|
145
145
|
});
|
|
146
146
|
|
|
147
147
|
// Create AI agent with GitHub-specific instructions
|
|
@@ -161,7 +161,7 @@ Always provide clear, concise responses with relevant information from GitHub.
|
|
|
161
161
|
});
|
|
162
162
|
|
|
163
163
|
// Example: Search for repositories
|
|
164
|
-
const result = await
|
|
164
|
+
const result = await aigne.invoke(
|
|
165
165
|
agent,
|
|
166
166
|
"Search for repositories related to 'modelcontextprotocol'"
|
|
167
167
|
);
|
|
@@ -174,8 +174,8 @@ console.log(result);
|
|
|
174
174
|
// 2. **modelcontextprotocol/modelcontextprotocol** - The main ModelContextProtocol repository
|
|
175
175
|
// ...
|
|
176
176
|
|
|
177
|
-
// Shutdown the
|
|
178
|
-
await
|
|
177
|
+
// Shutdown the aigne when done
|
|
178
|
+
await aigne.shutdown();
|
|
179
179
|
```
|
|
180
180
|
|
|
181
181
|
## Available GitHub Operations
|
package/index.test.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { expect, test } from "bun:test";
|
|
2
|
+
import { runExampleTest } from "@aigne/test-utils/run-example-test.js";
|
|
3
|
+
|
|
4
|
+
test(
|
|
5
|
+
"should successfully run the mcp-github",
|
|
6
|
+
async () => {
|
|
7
|
+
const { code } = await runExampleTest();
|
|
8
|
+
expect(code).toBe(0);
|
|
9
|
+
},
|
|
10
|
+
{ timeout: 600000 },
|
|
11
|
+
);
|
package/index.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import assert from "node:assert";
|
|
4
4
|
import { runChatLoopInTerminal } from "@aigne/cli/utils/run-chat-loop.js";
|
|
5
|
-
import { AIAgent,
|
|
5
|
+
import { AIAgent, AIGNE, MCPAgent } from "@aigne/core";
|
|
6
6
|
import { loadModel } from "@aigne/core/loader/index.js";
|
|
7
7
|
import { logger } from "@aigne/core/utils/logger.js";
|
|
8
8
|
|
|
@@ -22,9 +22,9 @@ const github = await MCPAgent.from({
|
|
|
22
22
|
},
|
|
23
23
|
});
|
|
24
24
|
|
|
25
|
-
const
|
|
25
|
+
const aigne = new AIGNE({
|
|
26
26
|
model,
|
|
27
|
-
|
|
27
|
+
skills: [github],
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
const agent = AIAgent.from({
|
|
@@ -43,7 +43,7 @@ Always provide clear, concise responses with relevant information from GitHub.
|
|
|
43
43
|
memory: true,
|
|
44
44
|
});
|
|
45
45
|
|
|
46
|
-
const userAgent =
|
|
46
|
+
const userAgent = aigne.invoke(agent);
|
|
47
47
|
|
|
48
48
|
await runChatLoopInTerminal(userAgent, {
|
|
49
49
|
welcome:
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aigne/example-mcp-github",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.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",
|
|
7
|
-
"license": "
|
|
7
|
+
"license": "MIT",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "git+https://github.com/AIGNE-io/aigne-framework"
|
|
@@ -18,11 +18,15 @@
|
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"openai": "^4.94.0",
|
|
20
20
|
"zod": "^3.24.2",
|
|
21
|
-
"@aigne/
|
|
22
|
-
"@aigne/
|
|
21
|
+
"@aigne/cli": "^1.8.0",
|
|
22
|
+
"@aigne/core": "^1.12.0"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@aigne/test-utils": "^0.1.0"
|
|
23
26
|
},
|
|
24
27
|
"scripts": {
|
|
25
28
|
"start": "bun run index.ts",
|
|
26
|
-
"lint": "tsc --noEmit"
|
|
29
|
+
"lint": "tsc --noEmit",
|
|
30
|
+
"test:llm": "bun test"
|
|
27
31
|
}
|
|
28
32
|
}
|
package/usages.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import assert from "node:assert";
|
|
2
|
-
import { AIAgent,
|
|
2
|
+
import { AIAgent, AIGNE, MCPAgent } from "@aigne/core";
|
|
3
3
|
import { OpenAIChatModel } from "@aigne/core/models/openai-chat-model.js";
|
|
4
4
|
|
|
5
5
|
const { OPENAI_API_KEY, GITHUB_TOKEN } = process.env;
|
|
@@ -18,9 +18,9 @@ const githubMCPAgent = await MCPAgent.from({
|
|
|
18
18
|
},
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
-
const
|
|
21
|
+
const aigne = new AIGNE({
|
|
22
22
|
model,
|
|
23
|
-
|
|
23
|
+
skills: [githubMCPAgent],
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
const agent = AIAgent.from({
|
|
@@ -40,7 +40,7 @@ Always provide clear, concise responses with relevant information from GitHub.
|
|
|
40
40
|
|
|
41
41
|
// Example 1: Search for repositories
|
|
42
42
|
console.log("Example 1: Searching for repositories");
|
|
43
|
-
const searchResult = await
|
|
43
|
+
const searchResult = await aigne.invoke(
|
|
44
44
|
agent,
|
|
45
45
|
"Search for repositories related to 'modelcontextprotocol' and limit to 3 results",
|
|
46
46
|
);
|
|
@@ -49,7 +49,7 @@ console.log("\n------------------------\n");
|
|
|
49
49
|
|
|
50
50
|
// Example 2: Get file contents
|
|
51
51
|
console.log("Example 2: Getting file contents");
|
|
52
|
-
const fileResult = await
|
|
52
|
+
const fileResult = await aigne.invoke(
|
|
53
53
|
agent,
|
|
54
54
|
"Get the content of README.md from modelcontextprotocol/servers repository",
|
|
55
55
|
);
|
|
@@ -58,10 +58,10 @@ console.log("\n------------------------\n");
|
|
|
58
58
|
|
|
59
59
|
// Example 3: List commits
|
|
60
60
|
console.log("Example 3: Listing commits");
|
|
61
|
-
const commitsResult = await
|
|
61
|
+
const commitsResult = await aigne.invoke(
|
|
62
62
|
agent,
|
|
63
63
|
"List the latest 3 commits from the modelcontextprotocol/servers repository",
|
|
64
64
|
);
|
|
65
65
|
console.log(commitsResult);
|
|
66
66
|
|
|
67
|
-
await
|
|
67
|
+
await aigne.shutdown();
|