@aigne/example-mcp-server 0.0.1-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.
@@ -0,0 +1,44 @@
1
+ # Change the name of this file to .env.local and fill in the following values
2
+
3
+ # Uncomment the lines below to enable debug logging
4
+ # DEBUG="aigne:*"
5
+
6
+ # Use different Models
7
+
8
+ # OpenAI
9
+ MODEL="openai:gpt-4.1"
10
+ OPENAI_API_KEY="YOUR_OPENAI_API_KEY"
11
+
12
+ # Anthropic claude
13
+ # MODEL="anthropic:claude-3-7-sonnet-latest"
14
+ # ANTHROPIC_API_KEY=""
15
+
16
+ # Gemini
17
+ # MODEL="gemini:gemini-2.0-flash"
18
+ # GEMINI_API_KEY=""
19
+
20
+ # Bedrock nova
21
+ # MODEL=bedrock:us.amazon.nova-premier-v1:0
22
+ # AWS_ACCESS_KEY_ID=""
23
+ # AWS_SECRET_ACCESS_KEY=""
24
+ # AWS_REGION=us-west-2
25
+
26
+ # DeepSeek
27
+ # MODEL="deepseek:deepseek-chat"
28
+ # DEEPSEEK_API_KEY=""
29
+
30
+ # OpenRouter
31
+ # MODEL="openrouter:openai/gpt-4o"
32
+ # OPEN_ROUTER_API_KEY=""
33
+
34
+ # xAI
35
+ # MODEL="xai:grok-2-latest"
36
+ # XAI_API_KEY=""
37
+
38
+ # Ollama
39
+ # MODEL="ollama:llama3.2"
40
+ # OLLAMA_DEFAULT_BASE_URL="http://localhost:11434/v1";
41
+
42
+
43
+ # Setup proxy if needed
44
+ # HTTPS_PROXY=http://localhost:7890
package/LICENSE.md 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 ADDED
@@ -0,0 +1,89 @@
1
+ # Chatbot Example
2
+
3
+ This example demonstrates how to create and run an agent-based chatbot using the [AIGNE Framework](https://github.com/AIGNE-io/aigne-framework) and [AIGNE CLI](https://github.com/AIGNE-io/aigne-framework/blob/main/packages/cli/README.md). The example now supports both one-shot and interactive chat modes, along with customizable model settings and pipeline input/output.
4
+
5
+ ## Prerequisites
6
+
7
+ * [Node.js](https://nodejs.org) and npm installed on your machine
8
+ * An [OpenAI API key](https://platform.openai.com/api-keys) for interacting with OpenAI's services
9
+
10
+ ## Quick Start (No Installation Required)
11
+
12
+ ```bash
13
+ export OPENAI_API_KEY=YOUR_OPENAI_API_KEY # Set your OpenAI API key
14
+
15
+ # Run in one-shot mode (default)
16
+ npx -y @aigne/example-chat-bot
17
+
18
+ # Run in interactive chat mode
19
+ npx -y @aigne/example-chat-bot --chat
20
+
21
+ # Use pipeline input
22
+ echo "Tell me about AIGNE Framework" | npx -y @aigne/example-chat-bot
23
+ ```
24
+
25
+ ## Installation
26
+
27
+ ### Install AIGNE CLI
28
+
29
+ ```bash
30
+ npm install -g @aigne/cli
31
+ ```
32
+
33
+ ### Clone the Repository
34
+
35
+ ```bash
36
+ git clone https://github.com/AIGNE-io/aigne-framework
37
+
38
+ cd aigne-framework/examples/chat-bot
39
+ ```
40
+
41
+ ### Setup Environment Variables
42
+
43
+ Setup your OpenAI API key in the `.env.local` file (you can rename `.env.local.example` to `.env.local`):
44
+
45
+ ```bash
46
+ OPENAI_API_KEY="" # Set your OpenAI API key here
47
+ ```
48
+
49
+ #### Using Different Models
50
+
51
+ You can use different AI models by setting the `MODEL` environment variable along with the corresponding API key. The framework supports multiple providers:
52
+
53
+ * **OpenAI**: `MODEL="openai:gpt-4.1"` with `OPENAI_API_KEY`
54
+ * **Anthropic**: `MODEL="anthropic:claude-3-7-sonnet-latest"` with `ANTHROPIC_API_KEY`
55
+ * **Google Gemini**: `MODEL="gemini:gemini-2.0-flash"` with `GEMINI_API_KEY`
56
+ * **AWS Bedrock**: `MODEL="bedrock:us.amazon.nova-premier-v1:0"` with AWS credentials
57
+ * **DeepSeek**: `MODEL="deepseek:deepseek-chat"` with `DEEPSEEK_API_KEY`
58
+ * **OpenRouter**: `MODEL="openrouter:openai/gpt-4o"` with `OPEN_ROUTER_API_KEY`
59
+ * **xAI**: `MODEL="xai:grok-2-latest"` with `XAI_API_KEY`
60
+ * **Ollama**: `MODEL="ollama:llama3.2"` with `OLLAMA_DEFAULT_BASE_URL`
61
+
62
+ For detailed configuration examples, please refer to the `.env.local.example` file in this directory.
63
+
64
+ ### Run the Example
65
+
66
+ ```bash
67
+ aigne run # Run in one-shot mode (default)
68
+
69
+ # Run in interactive chat mode
70
+ aigne run --chat
71
+
72
+ # Use pipeline input
73
+ echo "Tell me about AIGNE Framework" | aigne run
74
+ ```
75
+
76
+ ### Run Options
77
+
78
+ The example supports the following command-line parameters:
79
+
80
+ | Parameter | Description | Default |
81
+ |-----------|-------------|---------|
82
+ | `--chat` | Run in interactive chat mode | Disabled (one-shot mode) |
83
+ | `--model <provider[:model]>` | AI model to use in format 'provider\[:model]' where model is optional. Examples: 'openai' or 'openai:gpt-4o-mini' | openai |
84
+ | `--temperature <value>` | Temperature for model generation | Provider default |
85
+ | `--top-p <value>` | Top-p sampling value | Provider default |
86
+ | `--presence-penalty <value>` | Presence penalty value | Provider default |
87
+ | `--frequency-penalty <value>` | Frequency penalty value | Provider default |
88
+ | `--log-level <level>` | Set logging level (ERROR, WARN, INFO, DEBUG, TRACE) | INFO |
89
+ | `--input`, `-i <input>` | Specify input directly | None |
@@ -0,0 +1,5 @@
1
+ export default function currentTime() {
2
+ return {
3
+ currentTime: new Date().toISOString(),
4
+ };
5
+ }
@@ -0,0 +1,16 @@
1
+ name: poet
2
+ description: AI Poetry Writing Agent
3
+ instructions: |
4
+ You are a creative and thoughtful AI poet. You write beautiful, imaginative, and emotionally resonant poetry based on the given topic or prompt.
5
+ Use vivid imagery, metaphor, and elegant language. Your poems can follow any style or form, including free verse, haiku, or sonnet.
6
+ Be expressive and human-like in tone.
7
+
8
+ Write a poem about {{topic}}.
9
+ input_schema:
10
+ type: object
11
+ properties:
12
+ topic:
13
+ type: string
14
+ description: The topic or theme for the poem.
15
+ required:
16
+ - topic
@@ -0,0 +1,12 @@
1
+ import os from "node:os";
2
+
3
+ export default function systemInfo() {
4
+ return {
5
+ platform: os.platform(),
6
+ arch: os.arch(),
7
+ cpuCount: os.cpus().length,
8
+ totalMemory: `${(os.totalmem() / 1024 / 1024 / 1024).toFixed(2)} GB`,
9
+ freeMemory: `${(os.freemem() / 1024 / 1024 / 1024).toFixed(2)} GB`,
10
+ uptime: `${Math.floor(os.uptime() / 60)} min`,
11
+ };
12
+ }
package/aigne.yaml ADDED
@@ -0,0 +1,7 @@
1
+ chat_model:
2
+ name: gpt-4.1
3
+ temperature: 0.8
4
+ agents:
5
+ - agents/poet.yaml
6
+ - agents/current-time.js
7
+ - agents/system-info.js
package/index.js ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { spawnSync } from "node:child_process";
4
+ import { argv } from "node:process";
5
+
6
+ spawnSync("aigne", [...argv.slice(2)], {
7
+ stdio: "inherit",
8
+ cwd: import.meta.dirname,
9
+ });
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "@aigne/example-mcp-server",
3
+ "version": "0.0.1-0",
4
+ "description": "A demonstration of using AIGNE CLI to build a MCP server",
5
+ "author": "Arcblock <blocklet@arcblock.io> https://github.com/blocklet",
6
+ "homepage": "https://github.com/AIGNE-io/aigne-framework/tree/main/examples/mcp-server",
7
+ "license": "MIT",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/AIGNE-io/aigne-framework"
11
+ },
12
+ "type": "module",
13
+ "bin": "index.js",
14
+ "dependencies": {
15
+ "@aigne/cli": "^1.18.0"
16
+ },
17
+ "scripts": {
18
+ "test": "aigne test",
19
+ "test:llm": "aigne run"
20
+ }
21
+ }