@aigne/example-mcp-blocklet 1.17.5-beta → 1.17.5-beta.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.
@@ -44,4 +44,4 @@ OPENAI_API_KEY="YOUR_OPENAI_API_KEY"
44
44
  # HTTPS_PROXY=http://localhost:7890
45
45
 
46
46
  # Setup Blocklet app URL
47
- BLOCKLET_APP_URL="" # Your Blocklet app URL
47
+ BLOCKLET_APP_URL="https://xxx.xxxx.xxx" # Your Blocklet app URL
package/README.md CHANGED
@@ -20,8 +20,9 @@ This demo demonstrates how to use [AIGNE Framework](https://github.com/AIGNE-io/
20
20
 
21
21
  ## Quick Start (No Installation Required)
22
22
 
23
+ ### Run the Example
24
+
23
25
  ```bash
24
- export OPENAI_API_KEY=YOUR_OPENAI_API_KEY # Set your OpenAI API key
25
26
  export BLOCKLET_APP_URL="https://xxx.xxxx.xxx" # Your Blocklet app URL
26
27
 
27
28
  # Run in one-shot mode (default)
@@ -34,45 +35,62 @@ npx -y @aigne/example-mcp-blocklet --chat
34
35
  echo "What are the features of this blocklet app?" | npx -y @aigne/example-mcp-blocklet
35
36
  ```
36
37
 
37
- ## Installation
38
+ ### Connect to an AI Model
38
39
 
39
- ### Clone the Repository
40
+ As an example, running `npx -y @aigne/example-mcp-blocklet --chat` requires an AI model. If this is your first run, you need to connect one.
41
+
42
+ ![run example](./run-example.png)
43
+
44
+ - Connect via the official AIGNE Hub
45
+
46
+ Choose the first option and your browser will open the official AIGNE Hub page. Follow the prompts to complete the connection. If you're a new user, the system automatically grants 400,000 tokens for you to use.
47
+
48
+ ![connect to official aigne hub](../images/connect-to-aigne-hub.png)
49
+
50
+ - Connect via a self-hosted AIGNE Hub
51
+
52
+ Choose the second option, enter the URL of your self-hosted AIGNE Hub, and follow the prompts to complete the connection. If you need to set up a self-hosted AIGNE Hub, visit the Blocklet Store to install and deploy it: [Blocklet Store](https://store.blocklet.dev/blocklets/z8ia3xzq2tMq8CRHfaXj1BTYJyYnEcHbqP8cJ?utm_source=www.arcblock.io&utm_medium=blog_link&utm_campaign=default&utm_content=store.blocklet.dev#:~:text=%F0%9F%9A%80%20Get%20Started%20in%20Minutes).
53
+
54
+ ![connect to self hosted aigne hub](../images/connect-to-self-hosted-aigne-hub.png)
55
+
56
+ - Connect via a third-party model provider
57
+
58
+ Using OpenAI as an example, you can configure the provider's API key via environment variables. After configuration, run the example again:
40
59
 
41
60
  ```bash
42
- git clone https://github.com/AIGNE-io/aigne-framework
61
+ export OPENAI_API_KEY="" # Set your OpenAI API key here
43
62
  ```
63
+ For more details on third-party model configuration (e.g., OpenAI, DeepSeek, Google Gemini), see [.env.local.example](./.env.local.example).
44
64
 
45
- ### Install Dependencies
65
+ After configuration, run the example again.
46
66
 
47
- ```bash
48
- cd aigne-framework/examples/mcp-blocklet
67
+ ### Debugging
49
68
 
50
- pnpm install
51
- ```
69
+ The `aigne observe` command starts a local web server to monitor and analyze agent execution data. It provides a user-friendly interface to inspect traces, view detailed call information, and understand your agent’s behavior during runtime. This tool is essential for debugging, performance tuning, and gaining insight into how your agent processes information and interacts with tools and models.
70
+
71
+ Start the observation server.
52
72
 
53
- ### Setup Environment Variables
73
+ ![aigne-observe-execute](../images/aigne-observe-execute.png)
74
+
75
+ View a list of recent executions.
76
+
77
+ ![aigne-observe-list](../images/aigne-observe-list.png)
78
+
79
+ ## Installation
54
80
 
55
- Setup your OpenAI API key in the `.env.local` file:
81
+ ### Clone the Repository
56
82
 
57
83
  ```bash
58
- OPENAI_API_KEY="" # Set your OpenAI API key here
59
- BLOCKLET_APP_URL="" # Set your Blocklet app URL here
84
+ git clone https://github.com/AIGNE-io/aigne-framework
60
85
  ```
61
86
 
62
- #### Using Different Models
63
-
64
- You can use different AI models by setting the `MODEL` environment variable along with the corresponding API key. The framework supports multiple providers:
87
+ ### Install Dependencies
65
88
 
66
- * **OpenAI**: `MODEL="openai:gpt-4.1"` with `OPENAI_API_KEY`
67
- * **Anthropic**: `MODEL="anthropic:claude-3-7-sonnet-latest"` with `ANTHROPIC_API_KEY`
68
- * **Google Gemini**: `MODEL="gemini:gemini-2.0-flash"` with `GEMINI_API_KEY`
69
- * **AWS Bedrock**: `MODEL="bedrock:us.amazon.nova-premier-v1:0"` with AWS credentials
70
- * **DeepSeek**: `MODEL="deepseek:deepseek-chat"` with `DEEPSEEK_API_KEY`
71
- * **OpenRouter**: `MODEL="openrouter:openai/gpt-4o"` with `OPEN_ROUTER_API_KEY`
72
- * **xAI**: `MODEL="xai:grok-2-latest"` with `XAI_API_KEY`
73
- * **Ollama**: `MODEL="ollama:llama3.2"` with `OLLAMA_DEFAULT_BASE_URL`
89
+ ```bash
90
+ cd aigne-framework/examples/mcp-blocklet
74
91
 
75
- For detailed configuration examples, please refer to the `.env.local.example` file in this directory.
92
+ pnpm install
93
+ ```
76
94
 
77
95
  ### Run the Example
78
96
 
package/index.ts CHANGED
@@ -7,9 +7,12 @@ import { DefaultMemory } from "@aigne/default-memory";
7
7
  import { refreshAuthorization, UnauthorizedError } from "@modelcontextprotocol/sdk/client/auth.js";
8
8
  import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
9
9
  import JWT from "jsonwebtoken";
10
+ import { joinURL } from "ufo";
10
11
  import { TerminalOAuthProvider } from "./oauth.js";
11
12
 
12
- const rawUrl = process.argv[2] || process.env.BLOCKLET_APP_URL;
13
+ const rawUrl =
14
+ process.argv.find((arg) => arg.startsWith("https://") || arg.startsWith("http://")) ||
15
+ process.env.BLOCKLET_APP_URL;
13
16
  assert(
14
17
  rawUrl,
15
18
  "Please provide a blocklet url as an argument or set the BLOCKLET_APP_URL environment variable",
@@ -17,8 +20,7 @@ assert(
17
20
 
18
21
  const appUrl = new URL(rawUrl);
19
22
  try {
20
- appUrl.pathname = "/__blocklet__.js";
21
- const result = await fetch(appUrl.href);
23
+ const result = await fetch(joinURL(appUrl.href, "__blocklet__.js"));
22
24
  if (result.status !== 200) {
23
25
  console.error("Seems like the provided url is not a valid blocklet url: ", rawUrl);
24
26
  process.exit(1);
@@ -28,7 +30,6 @@ try {
28
30
  process.exit(1);
29
31
  }
30
32
 
31
- appUrl.pathname = "/.well-known/service/mcp";
32
33
  console.info("Connecting to blocklet", appUrl.href);
33
34
 
34
35
  let transport: StreamableHTTPClientTransport;
@@ -111,8 +112,9 @@ try {
111
112
 
112
113
  await runWithAIGNE(
113
114
  async () => {
115
+ const url = joinURL(appUrl.origin, "/.well-known/service/mcp");
114
116
  const blocklet = await MCPAgent.from({
115
- url: appUrl.href,
117
+ url,
116
118
  transport: "streamableHttp",
117
119
  opts: {
118
120
  authProvider: provider,
package/oauth.ts CHANGED
@@ -49,6 +49,9 @@ export class TerminalOAuthProvider extends EventEmitter implements OAuthClientPr
49
49
  contacts: ["support@aigne.io"],
50
50
  software_id: "AIGNE Framework",
51
51
  software_version: "1.0.0",
52
+
53
+ token_endpoint_auth_method: "client_secret_post",
54
+ jwks_uri: `${this.redirectUrl}/.well-known/jwks.json`,
52
55
  };
53
56
  }
54
57
 
@@ -79,6 +82,10 @@ export class TerminalOAuthProvider extends EventEmitter implements OAuthClientPr
79
82
  }
80
83
 
81
84
  async redirectToAuthorization(authorizationUrl: URL): Promise<void> {
85
+ console.log(
86
+ "🚀 redirectToAuthorization called, authorizationUrl:",
87
+ authorizationUrl.toString(),
88
+ );
82
89
  // Create a local server to handle the callback
83
90
  return new Promise((resolve, reject) => {
84
91
  const server = createServer(async (req, res) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aigne/example-mcp-blocklet",
3
- "version": "1.17.5-beta",
3
+ "version": "1.17.5-beta.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",
@@ -16,18 +16,19 @@
16
16
  "README.md"
17
17
  ],
18
18
  "dependencies": {
19
- "@modelcontextprotocol/sdk": "^1.18.0",
19
+ "@modelcontextprotocol/sdk": "^1.21.1",
20
20
  "jsonwebtoken": "^9.0.2",
21
21
  "open": "^10.2.0",
22
+ "ufo": "^1.6.1",
22
23
  "zod": "^3.25.67",
23
- "@aigne/agent-library": "^1.23.0-beta",
24
- "@aigne/cli": "^1.58.0-beta",
25
- "@aigne/core": "^1.71.0-beta",
26
- "@aigne/default-memory": "^1.3.5-beta"
24
+ "@aigne/agent-library": "^1.23.0-beta.1",
25
+ "@aigne/cli": "^1.58.0-beta.1",
26
+ "@aigne/core": "^1.71.0-beta.1",
27
+ "@aigne/default-memory": "^1.3.5-beta.1"
27
28
  },
28
29
  "devDependencies": {
29
30
  "@types/jsonwebtoken": "^9.0.10",
30
- "@aigne/test-utils": "^0.5.68-beta"
31
+ "@aigne/test-utils": "^0.5.68-beta.1"
31
32
  },
32
33
  "scripts": {
33
34
  "start": "bun run index.ts",