@equinor/fusion-framework-cli-plugin-ai-mcp 1.0.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/CHANGELOG.md +76 -0
- package/LICENSE +21 -0
- package/README.md +131 -0
- package/dist/esm/index.js +11 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/mcp.js +66 -0
- package/dist/esm/mcp.js.map +1 -0
- package/dist/esm/tools/fusion-search-api.js +65 -0
- package/dist/esm/tools/fusion-search-api.js.map +1 -0
- package/dist/esm/tools/fusion-search-cookbook.js +65 -0
- package/dist/esm/tools/fusion-search-cookbook.js.map +1 -0
- package/dist/esm/tools/fusion-search-eds.js +65 -0
- package/dist/esm/tools/fusion-search-eds.js.map +1 -0
- package/dist/esm/tools/fusion-search-markdown.js +65 -0
- package/dist/esm/tools/fusion-search-markdown.js.map +1 -0
- package/dist/esm/tools/fusion-search.tool.js +152 -0
- package/dist/esm/tools/fusion-search.tool.js.map +1 -0
- package/dist/esm/version.js +3 -0
- package/dist/esm/version.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/mcp.d.ts +2 -0
- package/dist/types/tools/fusion-search-api.d.ts +37 -0
- package/dist/types/tools/fusion-search-cookbook.d.ts +37 -0
- package/dist/types/tools/fusion-search-eds.d.ts +37 -0
- package/dist/types/tools/fusion-search-markdown.d.ts +37 -0
- package/dist/types/tools/fusion-search.tool.d.ts +52 -0
- package/dist/types/version.d.ts +1 -0
- package/package.json +61 -0
- package/src/index.ts +13 -0
- package/src/mcp.ts +130 -0
- package/src/tools/fusion-search-api.ts +90 -0
- package/src/tools/fusion-search-cookbook.ts +90 -0
- package/src/tools/fusion-search-eds.ts +91 -0
- package/src/tools/fusion-search-markdown.ts +90 -0
- package/src/tools/fusion-search.tool.ts +187 -0
- package/src/version.ts +2 -0
- package/tsconfig.json +24 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# @equinor/fusion-framework-cli-plugin-ai-mcp
|
|
2
|
+
|
|
3
|
+
## 1.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [`e2d2a76`](https://github.com/equinor/fusion-framework/commit/e2d2a76d08b86c3a9d8783fed1606551df9d5633) Thanks [@odinr](https://github.com/odinr)! - Add new MCP server plugin package for Model Context Protocol integration.
|
|
8
|
+
|
|
9
|
+
This plugin extends the Fusion Framework CLI with MCP server capabilities, enabling AI assistants to search and query Fusion Framework documentation through specialized semantic search tools.
|
|
10
|
+
|
|
11
|
+
**Features:**
|
|
12
|
+
|
|
13
|
+
- MCP protocol server implementation (stdio transport)
|
|
14
|
+
- Fusion Framework API reference search (TypeScript/TSDoc)
|
|
15
|
+
- Cookbook examples and tutorials search
|
|
16
|
+
- EDS component search (Storybook)
|
|
17
|
+
- Markdown documentation search
|
|
18
|
+
- Vector store integration via Azure Cognitive Search
|
|
19
|
+
|
|
20
|
+
**Quick Usage:**
|
|
21
|
+
|
|
22
|
+
1. Install the plugin:
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
pnpm add -D @equinor/fusion-framework-cli-plugin-ai-mcp
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
2. Configure in `fusion-cli.config.ts`:
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
import { defineFusionCli } from "@equinor/fusion-framework-cli";
|
|
32
|
+
|
|
33
|
+
export default defineFusionCli(() => ({
|
|
34
|
+
plugins: ["@equinor/fusion-framework-cli-plugin-ai-mcp"],
|
|
35
|
+
}));
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
3. Start the MCP server:
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
# Start MCP server (uses stdio by default)
|
|
42
|
+
ffc ai mcp
|
|
43
|
+
|
|
44
|
+
# With verbose output
|
|
45
|
+
ffc ai mcp --verbose
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
4. Configure in your AI assistant (e.g., Claude Desktop):
|
|
49
|
+
|
|
50
|
+
```json
|
|
51
|
+
{
|
|
52
|
+
"mcpServers": {
|
|
53
|
+
"fusion-framework": {
|
|
54
|
+
"command": "ffc",
|
|
55
|
+
"args": ["ai", "mcp"],
|
|
56
|
+
"env": {
|
|
57
|
+
"AZURE_OPENAI_API_KEY": "your-api-key",
|
|
58
|
+
"AZURE_OPENAI_INSTANCE_NAME": "your-instance",
|
|
59
|
+
"AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME": "your-embedding-deployment",
|
|
60
|
+
"AZURE_SEARCH_ENDPOINT": "https://your-search.search.windows.net",
|
|
61
|
+
"AZURE_SEARCH_API_KEY": "your-search-key",
|
|
62
|
+
"AZURE_SEARCH_INDEX_NAME": "your-index-name"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
The server exposes four specialized search tools: `fusion_search_markdown`, `fusion_search_api`, `fusion_search_cookbook`, and `fusion_search_eds` for semantic search across different documentation types.
|
|
70
|
+
|
|
71
|
+
### Patch Changes
|
|
72
|
+
|
|
73
|
+
- Updated dependencies [[`e2d2a76`](https://github.com/equinor/fusion-framework/commit/e2d2a76d08b86c3a9d8783fed1606551df9d5633), [`e2d2a76`](https://github.com/equinor/fusion-framework/commit/e2d2a76d08b86c3a9d8783fed1606551df9d5633), [`e2d2a76`](https://github.com/equinor/fusion-framework/commit/e2d2a76d08b86c3a9d8783fed1606551df9d5633)]:
|
|
74
|
+
- @equinor/fusion-framework-cli-plugin-ai-base@1.0.0
|
|
75
|
+
- @equinor/fusion-framework-cli@13.0.0
|
|
76
|
+
- @equinor/fusion-framework-module-ai@2.0.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Equinor
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# @equinor/fusion-framework-cli-plugin-ai-mcp
|
|
2
|
+
|
|
3
|
+
MCP server plugin for Fusion Framework CLI providing Model Context Protocol server capabilities for AI assistants.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
pnpm add -D @equinor/fusion-framework-cli-plugin-ai-mcp
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Configuration
|
|
12
|
+
|
|
13
|
+
After installing the plugin, create a `fusion-cli.config.ts` file in your project root:
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { defineFusionCli } from '@equinor/fusion-framework-cli';
|
|
17
|
+
|
|
18
|
+
export default defineFusionCli(() => ({
|
|
19
|
+
plugins: [
|
|
20
|
+
'@equinor/fusion-framework-cli-plugin-ai-mcp',
|
|
21
|
+
],
|
|
22
|
+
}));
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The CLI will automatically discover and load plugins listed in this configuration file. The config file can be `.ts`, `.js`, or `.json`. The `defineFusionCli` helper provides type safety and IntelliSense support.
|
|
26
|
+
|
|
27
|
+
## Features
|
|
28
|
+
|
|
29
|
+
This plugin extends the Fusion Framework CLI with MCP server capabilities:
|
|
30
|
+
|
|
31
|
+
- **MCP Protocol Server** - Implements the Model Context Protocol for AI assistant integration
|
|
32
|
+
- **Fusion Framework Tools** - Exposes tools for searching and querying the Fusion Framework codebase
|
|
33
|
+
- **Vector Store Integration** - Uses Azure Cognitive Search for semantic code search
|
|
34
|
+
- **Framework Information** - Provides tools to query framework configuration and capabilities
|
|
35
|
+
|
|
36
|
+
## Usage
|
|
37
|
+
|
|
38
|
+
Once installed, the MCP server command is automatically available:
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
# Start the MCP server (uses stdio by default)
|
|
42
|
+
ffc ai mcp
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Commands
|
|
46
|
+
|
|
47
|
+
### `ai mcp`
|
|
48
|
+
|
|
49
|
+
Starts a Model Context Protocol (MCP) server that provides tools and resources for AI assistants to interact with the Fusion Framework.
|
|
50
|
+
|
|
51
|
+
**Features:**
|
|
52
|
+
- Implements MCP protocol over stdio (standard for MCP servers)
|
|
53
|
+
- Exposes tools for semantic search of Fusion Framework codebase
|
|
54
|
+
- Provides framework information and configuration details
|
|
55
|
+
- Integrates with Azure Cognitive Search for vector-based code search
|
|
56
|
+
|
|
57
|
+
**Options:**
|
|
58
|
+
- `--openai-api-key <key>` - API key for Azure OpenAI (required)
|
|
59
|
+
- `--openai-api-version <version>` - API version (default: 2024-02-15-preview)
|
|
60
|
+
- `--openai-instance <name>` - Azure OpenAI instance name (required)
|
|
61
|
+
- `--openai-embedding-deployment <name>` - Azure OpenAI embedding deployment name (required for search)
|
|
62
|
+
- `--azure-search-endpoint <url>` - Azure Search endpoint URL (required for search)
|
|
63
|
+
- `--azure-search-api-key <key>` - Azure Search API key (required for search)
|
|
64
|
+
- `--azure-search-index-name <name>` - Azure Search index name (required for search)
|
|
65
|
+
- `--verbose` - Enable verbose output
|
|
66
|
+
|
|
67
|
+
**Examples:**
|
|
68
|
+
```sh
|
|
69
|
+
$ ffc ai mcp
|
|
70
|
+
$ ffc ai mcp --verbose
|
|
71
|
+
$ ffc ai mcp --azure-search-endpoint https://my-search.search.windows.net
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## MCP Tools
|
|
75
|
+
|
|
76
|
+
The server exposes the following tools:
|
|
77
|
+
|
|
78
|
+
### `fusion_search`
|
|
79
|
+
|
|
80
|
+
Search the Fusion Framework codebase and documentation using semantic search.
|
|
81
|
+
|
|
82
|
+
**Parameters:**
|
|
83
|
+
- `query` (string, required) - The search query to find relevant code or documentation
|
|
84
|
+
- `limit` (number, optional) - Maximum number of results to return (default: 5)
|
|
85
|
+
|
|
86
|
+
**Returns:**
|
|
87
|
+
- JSON object with search results including content and metadata
|
|
88
|
+
|
|
89
|
+
### `fusion_info`
|
|
90
|
+
|
|
91
|
+
Get information about the Fusion Framework instance and available modules.
|
|
92
|
+
|
|
93
|
+
**Parameters:**
|
|
94
|
+
- None
|
|
95
|
+
|
|
96
|
+
**Returns:**
|
|
97
|
+
- JSON object with framework version, module status, and service configuration
|
|
98
|
+
|
|
99
|
+
## Integration with AI Assistants
|
|
100
|
+
|
|
101
|
+
To use this MCP server with an AI assistant (like Claude Desktop, Cursor, etc.), configure the MCP server in your AI client's configuration file.
|
|
102
|
+
|
|
103
|
+
**Example configuration for Claude Desktop:**
|
|
104
|
+
|
|
105
|
+
```json
|
|
106
|
+
{
|
|
107
|
+
"mcpServers": {
|
|
108
|
+
"fusion-framework": {
|
|
109
|
+
"command": "ffc",
|
|
110
|
+
"args": ["ai", "mcp"],
|
|
111
|
+
"env": {
|
|
112
|
+
"AZURE_OPENAI_API_KEY": "your-api-key",
|
|
113
|
+
"AZURE_OPENAI_INSTANCE_NAME": "your-instance",
|
|
114
|
+
"AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME": "your-embedding-deployment",
|
|
115
|
+
"AZURE_SEARCH_ENDPOINT": "https://your-search.search.windows.net",
|
|
116
|
+
"AZURE_SEARCH_API_KEY": "your-search-key",
|
|
117
|
+
"AZURE_SEARCH_INDEX_NAME": "your-index-name"
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Configuration
|
|
125
|
+
|
|
126
|
+
The plugin requires Azure OpenAI and Azure Cognitive Search configuration for full functionality. See the main CLI documentation for details on setting up API keys and endpoints.
|
|
127
|
+
|
|
128
|
+
## License
|
|
129
|
+
|
|
130
|
+
ISC
|
|
131
|
+
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { registerAiPlugin as registerAiPluginBase } from '@equinor/fusion-framework-cli-plugin-ai-base';
|
|
2
|
+
import { command as mcpCommand } from './mcp.js';
|
|
3
|
+
/**
|
|
4
|
+
* Registers the AI MCP server plugin command with the CLI program
|
|
5
|
+
* @param program - The Commander program instance to register commands with
|
|
6
|
+
*/
|
|
7
|
+
export function registerAiPlugin(program) {
|
|
8
|
+
registerAiPluginBase(program, mcpCommand);
|
|
9
|
+
}
|
|
10
|
+
export default registerAiPlugin;
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,IAAI,oBAAoB,EAAE,MAAM,8CAA8C,CAAC;AACxG,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,UAAU,CAAC;AAEjD;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAgB;IAC/C,oBAAoB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;AAC5C,CAAC;AAED,eAAe,gBAAgB,CAAC"}
|
package/dist/esm/mcp.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { createCommand, createOption } from 'commander';
|
|
2
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
|
+
import { setupFramework } from '@equinor/fusion-framework-cli-plugin-ai-base';
|
|
5
|
+
import { withOptions as withAiOptions, } from '@equinor/fusion-framework-cli-plugin-ai-base/command-options';
|
|
6
|
+
import { handleTool as handleSearchTool, toolConfig as searchToolConfig, } from './tools/fusion-search.tool.js';
|
|
7
|
+
const _command = createCommand('mcp')
|
|
8
|
+
.description('Start a Model Context Protocol (MCP) server for Fusion Framework')
|
|
9
|
+
.addOption(createOption('--verbose', 'Enable verbose output').default(false))
|
|
10
|
+
.action(async (options) => {
|
|
11
|
+
if (options.verbose) {
|
|
12
|
+
console.error('🚀 Starting MCP server for Fusion Framework...');
|
|
13
|
+
}
|
|
14
|
+
// Initialize the framework
|
|
15
|
+
const framework = await setupFramework(options);
|
|
16
|
+
if (options.verbose) {
|
|
17
|
+
console.error('✅ Framework initialized successfully');
|
|
18
|
+
}
|
|
19
|
+
// Create MCP server instance
|
|
20
|
+
const server = new McpServer({
|
|
21
|
+
name: 'fusion-framework-mcp',
|
|
22
|
+
version: '1.0.0',
|
|
23
|
+
title: 'Fusion Framework MCP Server',
|
|
24
|
+
});
|
|
25
|
+
// Register search tool (will return error if not configured)
|
|
26
|
+
server.registerTool('fusion_search', searchToolConfig, handleSearchTool(framework, options));
|
|
27
|
+
if (options.verbose) {
|
|
28
|
+
if (options.azureSearchIndexName && framework.ai) {
|
|
29
|
+
console.error('✅ Registered tool: fusion_search');
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
console.error('⚠️ Registered tool: fusion_search (configuration missing - will return error when called)');
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
// Start the server using stdio transport (standard for MCP)
|
|
36
|
+
const transport = new StdioServerTransport();
|
|
37
|
+
await server.connect(transport);
|
|
38
|
+
if (options.verbose) {
|
|
39
|
+
console.error('✅ MCP server started and ready');
|
|
40
|
+
console.error('📡 Listening on stdio for MCP protocol messages');
|
|
41
|
+
}
|
|
42
|
+
// Keep the process alive
|
|
43
|
+
process.on('SIGINT', async () => {
|
|
44
|
+
if (options.verbose) {
|
|
45
|
+
console.error('\n🛑 Shutting down MCP server...');
|
|
46
|
+
}
|
|
47
|
+
await server.close();
|
|
48
|
+
process.exit(0);
|
|
49
|
+
});
|
|
50
|
+
process.on('SIGTERM', async () => {
|
|
51
|
+
if (options.verbose) {
|
|
52
|
+
console.error('\n🛑 Shutting down MCP server...');
|
|
53
|
+
}
|
|
54
|
+
await server.close();
|
|
55
|
+
process.exit(0);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
// Export the command with AI options
|
|
59
|
+
// Note: Search tools require embedding deployment, so we include it
|
|
60
|
+
export const command = withAiOptions(_command, {
|
|
61
|
+
includeChat: false,
|
|
62
|
+
includeEmbedding: true,
|
|
63
|
+
includeSearch: true,
|
|
64
|
+
});
|
|
65
|
+
export default command;
|
|
66
|
+
//# sourceMappingURL=mcp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.js","sourceRoot":"","sources":["../../src/mcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,MAAM,8CAA8C,CAAC;AAC9E,OAAO,EAEL,WAAW,IAAI,aAAa,G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;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAEhC,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,OAAO,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAC;QAChD,OAAO,CAAC,KAAK,CAAC,iDAAiD,CAAC,CAAC;IACnE,CAAC;IAED,yBAAyB;IACzB,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,KAAK,IAAI,EAAE;QAC9B,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YACpB,OAAO,CAAC,KAAK,CAAC,kCAAkC,CAAC,CAAC;QACpD,CAAC;QACD,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;QACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE;QAC/B,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YACpB,OAAO,CAAC,KAAK,CAAC,kCAAkC,CAAC,CAAC;QACpD,CAAC;QACD,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;QACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEL,qCAAqC;AACrC,oEAAoE;AACpE,MAAM,CAAC,MAAM,OAAO,GAAG,aAAa,CAAC,QAAQ,EAAE;IAC7C,WAAW,EAAE,KAAK;IAClB,gBAAgB,EAAE,IAAI;IACtB,aAAa,EAAE,IAAI;CACpB,CAAC,CAAC;AAEH,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool definition for searching Fusion Framework API reference.
|
|
3
|
+
* This tool enables semantic search across TypeScript/TSDoc code documentation, function signatures, and class definitions.
|
|
4
|
+
*/
|
|
5
|
+
export const toolDefinition = {
|
|
6
|
+
name: 'fusion_search_api',
|
|
7
|
+
description: 'Search the Fusion Framework API reference using semantic search. Use this for finding TypeScript/TSDoc code documentation, function signatures, class definitions, and API details.',
|
|
8
|
+
inputSchema: {
|
|
9
|
+
type: 'object',
|
|
10
|
+
properties: {
|
|
11
|
+
query: {
|
|
12
|
+
type: 'string',
|
|
13
|
+
description: 'The search query to find relevant API reference documentation',
|
|
14
|
+
},
|
|
15
|
+
limit: {
|
|
16
|
+
type: 'number',
|
|
17
|
+
description: 'Maximum number of results to return (default: 5)',
|
|
18
|
+
default: 5,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
required: ['query'],
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Tool handler for fusion_search_api
|
|
26
|
+
*/
|
|
27
|
+
export async function handleTool(args, framework, options) {
|
|
28
|
+
if (!options.azureSearchIndexName || !framework.ai) {
|
|
29
|
+
throw new Error('Vector store is not configured. Azure Search is required for search functionality.');
|
|
30
|
+
}
|
|
31
|
+
const query = args?.query;
|
|
32
|
+
const limit = args?.limit || 5;
|
|
33
|
+
if (!query || typeof query !== 'string') {
|
|
34
|
+
throw new Error('Query parameter is required and must be a string');
|
|
35
|
+
}
|
|
36
|
+
if (options.verbose) {
|
|
37
|
+
console.error(`🔍 Searching API reference for: ${query}`);
|
|
38
|
+
}
|
|
39
|
+
const vectorStoreService = framework.ai.getService('search', options.azureSearchIndexName);
|
|
40
|
+
const retriever = vectorStoreService.asRetriever({
|
|
41
|
+
k: limit,
|
|
42
|
+
searchType: 'similarity',
|
|
43
|
+
filter: {
|
|
44
|
+
filterExpression: "metadata/attributes/any(x: x/key eq 'type' and x/value eq 'tsdoc')",
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
const docs = await retriever.invoke(query);
|
|
48
|
+
return {
|
|
49
|
+
content: [
|
|
50
|
+
{
|
|
51
|
+
type: 'text',
|
|
52
|
+
text: JSON.stringify({
|
|
53
|
+
query,
|
|
54
|
+
type: 'api',
|
|
55
|
+
results: docs.map((doc) => ({
|
|
56
|
+
content: doc.pageContent,
|
|
57
|
+
metadata: doc.metadata,
|
|
58
|
+
})),
|
|
59
|
+
count: docs.length,
|
|
60
|
+
}, null, 2),
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=fusion-search-api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fusion-search-api.js","sourceRoot":"","sources":["../../../src/tools/fusion-search-api.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,mBAAmB;IACzB,WAAW,EACT,qLAAqL;IACvL,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,+DAA+D;aAC7E;YACD,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,kDAAkD;gBAC/D,OAAO,EAAE,CAAC;aACX;SACF;QACD,QAAQ,EAAE,CAAC,OAAO,CAAC;KACpB;CACO,CAAC;AAEX;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,IAA6B,EAC7B,SAA4B,EAC5B,OAA0C;IAK1C,IAAI,CAAC,OAAO,CAAC,oBAAoB,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,CAAC;QACnD,MAAM,IAAI,KAAK,CACb,oFAAoF,CACrF,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,EAAE,KAAe,CAAC;IACpC,MAAM,KAAK,GAAI,IAAI,EAAE,KAAgB,IAAI,CAAC,CAAC;IAE3C,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;IACtE,CAAC;IAED,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,OAAO,CAAC,KAAK,CAAC,mCAAmC,KAAK,EAAE,CAAC,CAAC;IAC5D,CAAC;IAED,MAAM,kBAAkB,GAAG,SAAS,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAC3F,MAAM,SAAS,GAAG,kBAAkB,CAAC,WAAW,CAAC;QAC/C,CAAC,EAAE,KAAK;QACR,UAAU,EAAE,YAAY;QACxB,MAAM,EAAE;YACN,gBAAgB,EAAE,oEAAoE;SACvF;KACF,CAAC,CAAC;IAEH,MAAM,IAAI,GAAG,MAAM,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAE3C,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAClB;oBACE,KAAK;oBACL,IAAI,EAAE,KAAK;oBACX,OAAO,EAAE,IAAI,CAAC,GAAG,CACf,CAAC,GAA+D,EAAE,EAAE,CAAC,CAAC;wBACpE,OAAO,EAAE,GAAG,CAAC,WAAW;wBACxB,QAAQ,EAAE,GAAG,CAAC,QAAQ;qBACvB,CAAC,CACH;oBACD,KAAK,EAAE,IAAI,CAAC,MAAM;iBACnB,EACD,IAAI,EACJ,CAAC,CACF;aACF;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool definition for searching Fusion Framework cookbooks.
|
|
3
|
+
* This tool enables semantic search across example implementations, tutorials, and how-to guides.
|
|
4
|
+
*/
|
|
5
|
+
export const toolDefinition = {
|
|
6
|
+
name: 'fusion_search_cookbook',
|
|
7
|
+
description: 'Search the Fusion Framework cookbooks using semantic search. Use this for finding example implementations, tutorials, guides, and how-to content.',
|
|
8
|
+
inputSchema: {
|
|
9
|
+
type: 'object',
|
|
10
|
+
properties: {
|
|
11
|
+
query: {
|
|
12
|
+
type: 'string',
|
|
13
|
+
description: 'The search query to find relevant cookbook examples and tutorials',
|
|
14
|
+
},
|
|
15
|
+
limit: {
|
|
16
|
+
type: 'number',
|
|
17
|
+
description: 'Maximum number of results to return (default: 5)',
|
|
18
|
+
default: 5,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
required: ['query'],
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Tool handler for fusion_search_cookbook
|
|
26
|
+
*/
|
|
27
|
+
export async function handleTool(args, framework, options) {
|
|
28
|
+
if (!options.azureSearchIndexName || !framework.ai) {
|
|
29
|
+
throw new Error('Vector store is not configured. Azure Search is required for search functionality.');
|
|
30
|
+
}
|
|
31
|
+
const query = args?.query;
|
|
32
|
+
const limit = args?.limit || 5;
|
|
33
|
+
if (!query || typeof query !== 'string') {
|
|
34
|
+
throw new Error('Query parameter is required and must be a string');
|
|
35
|
+
}
|
|
36
|
+
if (options.verbose) {
|
|
37
|
+
console.error(`🔍 Searching cookbooks for: ${query}`);
|
|
38
|
+
}
|
|
39
|
+
const vectorStoreService = framework.ai.getService('search', options.azureSearchIndexName);
|
|
40
|
+
const retriever = vectorStoreService.asRetriever({
|
|
41
|
+
k: limit,
|
|
42
|
+
searchType: 'similarity',
|
|
43
|
+
filter: {
|
|
44
|
+
filterExpression: "metadata/attributes/any(x: x/key eq 'type' and x/value eq 'cookbook')",
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
const docs = await retriever.invoke(query);
|
|
48
|
+
return {
|
|
49
|
+
content: [
|
|
50
|
+
{
|
|
51
|
+
type: 'text',
|
|
52
|
+
text: JSON.stringify({
|
|
53
|
+
query,
|
|
54
|
+
type: 'cookbook',
|
|
55
|
+
results: docs.map((doc) => ({
|
|
56
|
+
content: doc.pageContent,
|
|
57
|
+
metadata: doc.metadata,
|
|
58
|
+
})),
|
|
59
|
+
count: docs.length,
|
|
60
|
+
}, null, 2),
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=fusion-search-cookbook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fusion-search-cookbook.js","sourceRoot":"","sources":["../../../src/tools/fusion-search-cookbook.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,wBAAwB;IAC9B,WAAW,EACT,mJAAmJ;IACrJ,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,mEAAmE;aACjF;YACD,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,kDAAkD;gBAC/D,OAAO,EAAE,CAAC;aACX;SACF;QACD,QAAQ,EAAE,CAAC,OAAO,CAAC;KACpB;CACO,CAAC;AAEX;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,IAA6B,EAC7B,SAA4B,EAC5B,OAA0C;IAK1C,IAAI,CAAC,OAAO,CAAC,oBAAoB,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,CAAC;QACnD,MAAM,IAAI,KAAK,CACb,oFAAoF,CACrF,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,EAAE,KAAe,CAAC;IACpC,MAAM,KAAK,GAAI,IAAI,EAAE,KAAgB,IAAI,CAAC,CAAC;IAE3C,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;IACtE,CAAC;IAED,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,OAAO,CAAC,KAAK,CAAC,+BAA+B,KAAK,EAAE,CAAC,CAAC;IACxD,CAAC;IAED,MAAM,kBAAkB,GAAG,SAAS,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAC3F,MAAM,SAAS,GAAG,kBAAkB,CAAC,WAAW,CAAC;QAC/C,CAAC,EAAE,KAAK;QACR,UAAU,EAAE,YAAY;QACxB,MAAM,EAAE;YACN,gBAAgB,EAAE,uEAAuE;SAC1F;KACF,CAAC,CAAC;IAEH,MAAM,IAAI,GAAG,MAAM,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAE3C,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAClB;oBACE,KAAK;oBACL,IAAI,EAAE,UAAU;oBAChB,OAAO,EAAE,IAAI,CAAC,GAAG,CACf,CAAC,GAA+D,EAAE,EAAE,CAAC,CAAC;wBACpE,OAAO,EAAE,GAAG,CAAC,WAAW;wBACxB,QAAQ,EAAE,GAAG,CAAC,QAAQ;qBACvB,CAAC,CACH;oBACD,KAAK,EAAE,IAAI,CAAC,MAAM;iBACnB,EACD,IAAI,EACJ,CAAC,CACF;aACF;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool definition for searching EDS (Equinor Design System) components from Storybook.
|
|
3
|
+
* This tool enables semantic search across component examples, props, usage patterns, and Storybook stories.
|
|
4
|
+
*/
|
|
5
|
+
export const toolDefinition = {
|
|
6
|
+
name: 'fusion_search_eds',
|
|
7
|
+
description: 'Search EDS (Equinor Design System) components from Storybook using semantic search. Use this for finding component examples, props, usage patterns, and Storybook stories.',
|
|
8
|
+
inputSchema: {
|
|
9
|
+
type: 'object',
|
|
10
|
+
properties: {
|
|
11
|
+
query: {
|
|
12
|
+
type: 'string',
|
|
13
|
+
description: 'The search query to find relevant EDS component examples and Storybook stories',
|
|
14
|
+
},
|
|
15
|
+
limit: {
|
|
16
|
+
type: 'number',
|
|
17
|
+
description: 'Maximum number of results to return (default: 5)',
|
|
18
|
+
default: 5,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
required: ['query'],
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Tool handler for fusion_search_eds
|
|
26
|
+
*/
|
|
27
|
+
export async function handleTool(args, framework, options) {
|
|
28
|
+
if (!options.azureSearchIndexName || !framework.ai) {
|
|
29
|
+
throw new Error('Vector store is not configured. Azure Search is required for search functionality.');
|
|
30
|
+
}
|
|
31
|
+
const query = args?.query;
|
|
32
|
+
const limit = args?.limit || 5;
|
|
33
|
+
if (!query || typeof query !== 'string') {
|
|
34
|
+
throw new Error('Query parameter is required and must be a string');
|
|
35
|
+
}
|
|
36
|
+
if (options.verbose) {
|
|
37
|
+
console.error(`🔍 Searching EDS components/Storybook for: ${query}`);
|
|
38
|
+
}
|
|
39
|
+
const vectorStoreService = framework.ai.getService('search', options.azureSearchIndexName);
|
|
40
|
+
const retriever = vectorStoreService.asRetriever({
|
|
41
|
+
k: limit,
|
|
42
|
+
searchType: 'similarity',
|
|
43
|
+
filter: {
|
|
44
|
+
filterExpression: "metadata/attributes/any(x: x/key eq 'type' and x/value eq 'storybook')",
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
const docs = await retriever.invoke(query);
|
|
48
|
+
return {
|
|
49
|
+
content: [
|
|
50
|
+
{
|
|
51
|
+
type: 'text',
|
|
52
|
+
text: JSON.stringify({
|
|
53
|
+
query,
|
|
54
|
+
type: 'eds-component',
|
|
55
|
+
results: docs.map((doc) => ({
|
|
56
|
+
content: doc.pageContent,
|
|
57
|
+
metadata: doc.metadata,
|
|
58
|
+
})),
|
|
59
|
+
count: docs.length,
|
|
60
|
+
}, null, 2),
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=fusion-search-eds.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fusion-search-eds.js","sourceRoot":"","sources":["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B,MAAM,EAAE;YACN,gBAAgB,EAAE,wEAAwE;SAC3F;KACF,CAAC,CAAC;IAEH,MAAM,IAAI,GAAG,MAAM,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAE3C,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAClB;oBACE,KAAK;oBACL,IAAI,EAAE,eAAe;oBACrB,OAAO,EAAE,IAAI,CAAC,GAAG,CACf,CAAC,GAA+D,EAAE,EAAE,CAAC,CAAC;wBACpE,OAAO,EAAE,GAAG,CAAC,WAAW;wBACxB,QAAQ,EAAE,GAAG,CAAC,QAAQ;qBACvB,CAAC,CACH;oBACD,KAAK,EAAE,IAAI,CAAC,MAAM;iBACnB,EACD,IAAI,EACJ,CAAC,CACF;aACF;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool definition for searching Fusion Framework markdown documentation.
|
|
3
|
+
* This tool enables semantic search across markdown files, guides, and documentation.
|
|
4
|
+
*/
|
|
5
|
+
export const toolDefinition = {
|
|
6
|
+
name: 'fusion_search_markdown',
|
|
7
|
+
description: 'Search the Fusion Framework markdown documentation using semantic search. Use this for finding documentation, guides, and explanatory content.',
|
|
8
|
+
inputSchema: {
|
|
9
|
+
type: 'object',
|
|
10
|
+
properties: {
|
|
11
|
+
query: {
|
|
12
|
+
type: 'string',
|
|
13
|
+
description: 'The search query to find relevant markdown documentation',
|
|
14
|
+
},
|
|
15
|
+
limit: {
|
|
16
|
+
type: 'number',
|
|
17
|
+
description: 'Maximum number of results to return (default: 5)',
|
|
18
|
+
default: 5,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
required: ['query'],
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Tool handler for fusion_search_markdown
|
|
26
|
+
*/
|
|
27
|
+
export async function handleTool(args, framework, options) {
|
|
28
|
+
if (!options.azureSearchIndexName || !framework.ai) {
|
|
29
|
+
throw new Error('Vector store is not configured. Azure Search is required for search functionality.');
|
|
30
|
+
}
|
|
31
|
+
const query = args?.query;
|
|
32
|
+
const limit = args?.limit || 5;
|
|
33
|
+
if (!query || typeof query !== 'string') {
|
|
34
|
+
throw new Error('Query parameter is required and must be a string');
|
|
35
|
+
}
|
|
36
|
+
if (options.verbose) {
|
|
37
|
+
console.error(`🔍 Searching markdown documentation for: ${query}`);
|
|
38
|
+
}
|
|
39
|
+
const vectorStoreService = framework.ai.getService('search', options.azureSearchIndexName);
|
|
40
|
+
const retriever = vectorStoreService.asRetriever({
|
|
41
|
+
k: limit,
|
|
42
|
+
searchType: 'similarity',
|
|
43
|
+
filter: {
|
|
44
|
+
filterExpression: "metadata/attributes/any(x: x/key eq 'type' and x/value eq 'markdown')",
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
const docs = await retriever.invoke(query);
|
|
48
|
+
return {
|
|
49
|
+
content: [
|
|
50
|
+
{
|
|
51
|
+
type: 'text',
|
|
52
|
+
text: JSON.stringify({
|
|
53
|
+
query,
|
|
54
|
+
type: 'markdown',
|
|
55
|
+
results: docs.map((doc) => ({
|
|
56
|
+
content: doc.pageContent,
|
|
57
|
+
metadata: doc.metadata,
|
|
58
|
+
})),
|
|
59
|
+
count: docs.length,
|
|
60
|
+
}, null, 2),
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=fusion-search-markdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fusion-search-markdown.js","sourceRoot":"","sources":["../../../src/tools/fusion-search-markdown.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,wBAAwB;IAC9B,WAAW,EACT,gJAAgJ;IAClJ,WAAW,EAAE;QACX,IAAI,EAAE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