@aigne/example-mcp-blocklet 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/README.md +10 -8
- package/index.ts +4 -7
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
# MCP Blocklet Demo
|
|
2
2
|
|
|
3
|
-
This
|
|
3
|
+
This demo demonstrates how to use [AIGNE Framework](https://github.com/AIGNE-io/aigne-framework) and MCP to interact with apps hosted on the [Blocklet platform](https://github.com/blocklet).
|
|
4
4
|
|
|
5
5
|
## Prerequisites
|
|
6
6
|
|
|
7
7
|
- [Node.js](https://nodejs.org) and npm installed on your machine
|
|
8
|
-
- [OpenAI API key](https://platform.openai.com/api-keys)
|
|
9
|
-
-
|
|
8
|
+
- An [OpenAI API key](https://platform.openai.com/api-keys) for interacting with OpenAI's services
|
|
9
|
+
- Optional dependencies (if running the example from source code):
|
|
10
|
+
- [Bun](https://bun.sh) for running unit tests & examples
|
|
11
|
+
- [Pnpm](https://pnpm.io) for package management
|
|
10
12
|
|
|
11
|
-
##
|
|
13
|
+
## Quick Start (No Installation Required)
|
|
12
14
|
|
|
13
15
|
```bash
|
|
14
|
-
export OPENAI_API_KEY=YOUR_OPENAI_API_KEY #
|
|
16
|
+
export OPENAI_API_KEY=YOUR_OPENAI_API_KEY # Set your OpenAI API key
|
|
15
17
|
|
|
16
|
-
npx -y @aigne/example-mcp-blocklet #
|
|
18
|
+
npx -y @aigne/example-mcp-blocklet # Run the example
|
|
17
19
|
```
|
|
18
20
|
|
|
19
21
|
## Installation
|
|
@@ -37,8 +39,8 @@ pnpm install
|
|
|
37
39
|
Setup your OpenAI API key in the `.env.local` file:
|
|
38
40
|
|
|
39
41
|
```bash
|
|
40
|
-
OPENAI_API_KEY="" #
|
|
41
|
-
BLOCKLET_APP_URL="" #
|
|
42
|
+
OPENAI_API_KEY="" # Set your OpenAI API key here
|
|
43
|
+
BLOCKLET_APP_URL="" # Set your Blocklet app URL here
|
|
42
44
|
```
|
|
43
45
|
|
|
44
46
|
### Run the Example
|
package/index.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
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, PromptBuilder } 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
|
import { UnauthorizedError, refreshAuthorization } from "@modelcontextprotocol/sdk/client/auth.js";
|
|
9
9
|
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
|
|
@@ -14,8 +14,7 @@ import { TerminalOAuthProvider } from "./oauth.js";
|
|
|
14
14
|
|
|
15
15
|
logger.enable(`aigne:mcp,${process.env.DEBUG}`);
|
|
16
16
|
|
|
17
|
-
const {
|
|
18
|
-
assert(OPENAI_API_KEY, "Please set the OPENAI_API_KEY environment variable");
|
|
17
|
+
const { BLOCKLET_APP_URL } = process.env;
|
|
19
18
|
assert(BLOCKLET_APP_URL, "Please set the BLOCKLET_APP_URL environment variable");
|
|
20
19
|
console.info("Connecting to blocklet app", BLOCKLET_APP_URL);
|
|
21
20
|
|
|
@@ -90,9 +89,7 @@ try {
|
|
|
90
89
|
|
|
91
90
|
console.info("Starting connecting to blocklet mcp...");
|
|
92
91
|
|
|
93
|
-
const model =
|
|
94
|
-
apiKey: OPENAI_API_KEY,
|
|
95
|
-
});
|
|
92
|
+
const model = await loadModel();
|
|
96
93
|
|
|
97
94
|
const blocklet = await MCPAgent.from({
|
|
98
95
|
url: appUrl.href,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aigne/example-mcp-blocklet",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.1",
|
|
4
4
|
"description": "A demonstration of using AIGNE Framework and MCP Server hosted by the Blocklet platform",
|
|
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-blocklet",
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
"jsonwebtoken": "^9.0.2",
|
|
21
21
|
"open": "^10.1.0",
|
|
22
22
|
"zod": "^3.24.2",
|
|
23
|
-
"@aigne/cli": "^1.
|
|
24
|
-
"@aigne/core": "^1.
|
|
23
|
+
"@aigne/cli": "^1.5.1",
|
|
24
|
+
"@aigne/core": "^1.10.0"
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
|
-
"start": "
|
|
27
|
+
"start": "bun run index.ts",
|
|
28
28
|
"lint": "tsc --noEmit"
|
|
29
29
|
}
|
|
30
30
|
}
|