@teambit/cli-mcp-server 0.0.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.
@@ -0,0 +1,163 @@
1
+ # Bit CLI MCP Server
2
+
3
+ The Bit CLI MCP Server provides a [Model Context Protocol (MCP)](https://github.com/modelcontextprotocol/mcp) interface to Bit's command-line functionality, enabling programmatic access to Bit workspace and component management operations. This server exposes Bit CLI commands as MCP tools, making it possible to automate, script, or integrate Bit operations with other tools and platforms.
4
+
5
+ ## Overview
6
+
7
+ This server acts as a bridge between MCP clients (such as VS Code, AI tools, or your own applications) and the Bit CLI. It translates MCP tool calls into Bit CLI commands, runs them, and returns the results in a format that MCP clients can understand.
8
+
9
+ ## Installation
10
+
11
+ ### Prerequisites
12
+
13
+ - Node.js (v18 or later recommended)
14
+ - Bit CLI installed and available in your PATH
15
+
16
+ ### Getting Started
17
+
18
+ The Bit CLI MCP Server is included with Bit. If you have Bit installed, you can run the server using:
19
+
20
+ ```
21
+ bit mcp-server
22
+ ```
23
+
24
+ ## Usage
25
+
26
+ ### Command-Line Options
27
+
28
+ ```
29
+ bit mcp-server [options]
30
+ ```
31
+
32
+ Options:
33
+
34
+ - `-e, --extended`: Enable the full set of Bit CLI commands as MCP tools
35
+ - `--include-only <commands>`: Specify a subset of commands to expose as MCP tools (comma-separated list)
36
+ - `--include-additional <commands>`: Add specific commands to the default set (comma-separated list)
37
+ - `--exclude <commands>`: Prevent specific commands from being exposed (comma-separated list)
38
+
39
+ ### Integrating with VS Code
40
+
41
+ To use this MCP server in VS Code:
42
+
43
+ 1. Open VS Code settings (JSON) by pressing `Ctrl + Shift + P` and typing `Preferences: Open Settings (JSON)`
44
+ 2. Add the following JSON block:
45
+
46
+ ```json
47
+ {
48
+ "mcp": {
49
+ "servers": {
50
+ "bit-cli": {
51
+ "command": "bit",
52
+ "args": ["mcp-server"]
53
+ }
54
+ }
55
+ }
56
+ }
57
+ ```
58
+
59
+ For extended mode with all commands available:
60
+
61
+ ```json
62
+ {
63
+ "mcp": {
64
+ "servers": {
65
+ "bit-cli": {
66
+ "command": "bit",
67
+ "args": ["mcp-server", "--extended"]
68
+ }
69
+ }
70
+ }
71
+ }
72
+ ```
73
+
74
+ ### Programmatic Usage
75
+
76
+ ```javascript
77
+ import { McpClient } from '@modelcontextprotocol/sdk/client';
78
+
79
+ async function example() {
80
+ const client = await McpClient.spawn('bit', ['mcp-server']);
81
+
82
+ // Call a Bit CLI tool via MCP
83
+ const result = await client.callTool('bit_status', { cwd: '/path/to/workspace' });
84
+ console.log(result.content[0].text);
85
+
86
+ // Close the connection when done
87
+ await client.close();
88
+ }
89
+ ```
90
+
91
+ ## Available Tools
92
+
93
+ The Bit CLI MCP Server operates in two modes:
94
+
95
+ ### Default Mode
96
+
97
+ In default mode, the server exposes a focused set of essential Bit CLI commands (~20 tools). This ensures optimal performance and safety. These are the most commonly used Bit operations:
98
+
99
+ - `bit_status`: Show component status and potential issues
100
+ - `bit_list`: List components in a workspace or remote scope
101
+ - `bit_add`: Track directories as components
102
+ - `bit_init`: Create or initialize a workspace
103
+ - `bit_show`: Display component information
104
+ - `bit_tag`: Create an immutable, exportable component version
105
+ - `bit_snap`: Create a non-release component snapshot
106
+ - `bit_import`: Import components from remote scopes
107
+ - `bit_export`: Export components to remote scopes
108
+ - `bit_remove`: Remove components from workspace
109
+ - `bit_log`: Show component version history
110
+ - `bit_test`: Test components
111
+ - `bit_diff`: Show differences between component versions
112
+ - `bit_install`: Install dependencies
113
+ - `bit_lane_show`: Display lane details
114
+ - `bit_lane_create`: Create a new development lane
115
+ - `bit_lane_switch`: Switch between lanes
116
+ - `bit_lane_merge`: Merge lane changes
117
+ - `bit_create`: Generate components from templates
118
+ - `bit_templates`: List available templates
119
+ - `bit_reset`: Revert tags or snaps
120
+ - `bit_checkout`: Switch versions or remove changes
121
+
122
+ ### Extended Mode (--extended)
123
+
124
+ When started with the `--extended` flag, the server exposes nearly all Bit CLI commands as MCP tools, including:
125
+
126
+ - All lane sub-commands (remove, alias, rename, diff, change-scope, import, fetch, eject, history, etc.)
127
+ - Development tools (build, lint, format)
128
+ - Package management (uninstall, update)
129
+ - Component operations (recover, fork, rename)
130
+ - Workspace management (ws-config, stash, aspect)
131
+ - Analysis tools (insight, deps, why)
132
+ - And many more
133
+
134
+ > **Note:** When using extended mode, some AI models (particularly Gemini and ChatGPT) may struggle with the high number of available tools and respond with "400 Bad Request" or "500 Server Error" errors. This is not due to any issue with specific tools, but rather with how these models handle large tool sets. Claude Sonnet tends to handle extended mode better. If you encounter these errors, try using default mode or selectively adding only the tools you need via the `--include-additional` flag.
135
+
136
+ ## Tool Parameters
137
+
138
+ All tools accept a `cwd` parameter specifying the workspace path. Additional parameters vary by command.
139
+
140
+ Example tool call for `bit_status`:
141
+
142
+ ```json
143
+ {
144
+ "cwd": "/path/to/workspace",
145
+ "warnings": true,
146
+ "json": true
147
+ }
148
+ ```
149
+
150
+ ## Custom Tool Selection
151
+
152
+ To customize the available tools beyond the default set or extended mode:
153
+
154
+ ```
155
+ # Include only specific tools
156
+ bit mcp-server --include-only "status,show,tag,snap,import,export"
157
+
158
+ # Add specific tools to the default set
159
+ bit mcp-server --include-additional "build,lint,format"
160
+
161
+ # Exclude specific tools from being available
162
+ bit mcp-server --extended --exclude "checkout,remove"
163
+ ```
@@ -0,0 +1,163 @@
1
+ # Bit CLI MCP Server
2
+
3
+ The Bit CLI MCP Server provides a [Model Context Protocol (MCP)](https://github.com/modelcontextprotocol/mcp) interface to Bit's command-line functionality, enabling programmatic access to Bit workspace and component management operations. This server exposes Bit CLI commands as MCP tools, making it possible to automate, script, or integrate Bit operations with other tools and platforms.
4
+
5
+ ## Overview
6
+
7
+ This server acts as a bridge between MCP clients (such as VS Code, AI tools, or your own applications) and the Bit CLI. It translates MCP tool calls into Bit CLI commands, runs them, and returns the results in a format that MCP clients can understand.
8
+
9
+ ## Installation
10
+
11
+ ### Prerequisites
12
+
13
+ - Node.js (v18 or later recommended)
14
+ - Bit CLI installed and available in your PATH
15
+
16
+ ### Getting Started
17
+
18
+ The Bit CLI MCP Server is included with Bit. If you have Bit installed, you can run the server using:
19
+
20
+ ```
21
+ bit mcp-server
22
+ ```
23
+
24
+ ## Usage
25
+
26
+ ### Command-Line Options
27
+
28
+ ```
29
+ bit mcp-server [options]
30
+ ```
31
+
32
+ Options:
33
+
34
+ - `-e, --extended`: Enable the full set of Bit CLI commands as MCP tools
35
+ - `--include-only <commands>`: Specify a subset of commands to expose as MCP tools (comma-separated list)
36
+ - `--include-additional <commands>`: Add specific commands to the default set (comma-separated list)
37
+ - `--exclude <commands>`: Prevent specific commands from being exposed (comma-separated list)
38
+
39
+ ### Integrating with VS Code
40
+
41
+ To use this MCP server in VS Code:
42
+
43
+ 1. Open VS Code settings (JSON) by pressing `Ctrl + Shift + P` and typing `Preferences: Open Settings (JSON)`
44
+ 2. Add the following JSON block:
45
+
46
+ ```json
47
+ {
48
+ "mcp": {
49
+ "servers": {
50
+ "bit-cli": {
51
+ "command": "bit",
52
+ "args": ["mcp-server"]
53
+ }
54
+ }
55
+ }
56
+ }
57
+ ```
58
+
59
+ For extended mode with all commands available:
60
+
61
+ ```json
62
+ {
63
+ "mcp": {
64
+ "servers": {
65
+ "bit-cli": {
66
+ "command": "bit",
67
+ "args": ["mcp-server", "--extended"]
68
+ }
69
+ }
70
+ }
71
+ }
72
+ ```
73
+
74
+ ### Programmatic Usage
75
+
76
+ ```javascript
77
+ import { McpClient } from '@modelcontextprotocol/sdk/client';
78
+
79
+ async function example() {
80
+ const client = await McpClient.spawn('bit', ['mcp-server']);
81
+
82
+ // Call a Bit CLI tool via MCP
83
+ const result = await client.callTool('bit_status', { cwd: '/path/to/workspace' });
84
+ console.log(result.content[0].text);
85
+
86
+ // Close the connection when done
87
+ await client.close();
88
+ }
89
+ ```
90
+
91
+ ## Available Tools
92
+
93
+ The Bit CLI MCP Server operates in two modes:
94
+
95
+ ### Default Mode
96
+
97
+ In default mode, the server exposes a focused set of essential Bit CLI commands (~20 tools). This ensures optimal performance and safety. These are the most commonly used Bit operations:
98
+
99
+ - `bit_status`: Show component status and potential issues
100
+ - `bit_list`: List components in a workspace or remote scope
101
+ - `bit_add`: Track directories as components
102
+ - `bit_init`: Create or initialize a workspace
103
+ - `bit_show`: Display component information
104
+ - `bit_tag`: Create an immutable, exportable component version
105
+ - `bit_snap`: Create a non-release component snapshot
106
+ - `bit_import`: Import components from remote scopes
107
+ - `bit_export`: Export components to remote scopes
108
+ - `bit_remove`: Remove components from workspace
109
+ - `bit_log`: Show component version history
110
+ - `bit_test`: Test components
111
+ - `bit_diff`: Show differences between component versions
112
+ - `bit_install`: Install dependencies
113
+ - `bit_lane_show`: Display lane details
114
+ - `bit_lane_create`: Create a new development lane
115
+ - `bit_lane_switch`: Switch between lanes
116
+ - `bit_lane_merge`: Merge lane changes
117
+ - `bit_create`: Generate components from templates
118
+ - `bit_templates`: List available templates
119
+ - `bit_reset`: Revert tags or snaps
120
+ - `bit_checkout`: Switch versions or remove changes
121
+
122
+ ### Extended Mode (--extended)
123
+
124
+ When started with the `--extended` flag, the server exposes nearly all Bit CLI commands as MCP tools, including:
125
+
126
+ - All lane sub-commands (remove, alias, rename, diff, change-scope, import, fetch, eject, history, etc.)
127
+ - Development tools (build, lint, format)
128
+ - Package management (uninstall, update)
129
+ - Component operations (recover, fork, rename)
130
+ - Workspace management (ws-config, stash, aspect)
131
+ - Analysis tools (insight, deps, why)
132
+ - And many more
133
+
134
+ > **Note:** When using extended mode, some AI models (particularly Gemini and ChatGPT) may struggle with the high number of available tools and respond with "400 Bad Request" or "500 Server Error" errors. This is not due to any issue with specific tools, but rather with how these models handle large tool sets. Claude Sonnet tends to handle extended mode better. If you encounter these errors, try using default mode or selectively adding only the tools you need via the `--include-additional` flag.
135
+
136
+ ## Tool Parameters
137
+
138
+ All tools accept a `cwd` parameter specifying the workspace path. Additional parameters vary by command.
139
+
140
+ Example tool call for `bit_status`:
141
+
142
+ ```json
143
+ {
144
+ "cwd": "/path/to/workspace",
145
+ "warnings": true,
146
+ "json": true
147
+ }
148
+ ```
149
+
150
+ ## Custom Tool Selection
151
+
152
+ To customize the available tools beyond the default set or extended mode:
153
+
154
+ ```
155
+ # Include only specific tools
156
+ bit mcp-server --include-only "status,show,tag,snap,import,export"
157
+
158
+ # Add specific tools to the default set
159
+ bit mcp-server --include-additional "build,lint,format"
160
+
161
+ # Exclude specific tools from being available
162
+ bit mcp-server --extended --exclude "checkout,remove"
163
+ ```
@@ -0,0 +1,2 @@
1
+ import { Aspect } from '@teambit/harmony';
2
+ export declare const CliMcpServerAspect: Aspect;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.CliMcpServerAspect = void 0;
7
+ function _harmony() {
8
+ const data = require("@teambit/harmony");
9
+ _harmony = function () {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ const CliMcpServerAspect = exports.CliMcpServerAspect = _harmony().Aspect.create({
15
+ id: 'teambit.mcp/cli-mcp-server'
16
+ });
17
+
18
+ //# sourceMappingURL=cli-mcp-server.aspect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_harmony","data","require","CliMcpServerAspect","exports","Aspect","create","id"],"sources":["cli-mcp-server.aspect.ts"],"sourcesContent":["import { Aspect } from '@teambit/harmony';\n\nexport const CliMcpServerAspect = Aspect.create({\n id: 'teambit.mcp/cli-mcp-server',\n});\n "],"mappings":";;;;;;AAAA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEO,MAAME,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,GAAGE,iBAAM,CAACC,MAAM,CAAC;EAC9CC,EAAE,EAAE;AACN,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,24 @@
1
+ import { CLIMain } from '@teambit/cli';
2
+ import { Logger, LoggerMain } from '@teambit/logger';
3
+ export declare class CliMcpServerMain {
4
+ private cli;
5
+ private logger;
6
+ constructor(cli: CLIMain, logger: Logger);
7
+ private shouldIncludeCommand;
8
+ private buildZodSchema;
9
+ private buildCommandArgs;
10
+ private registerToolForCommand;
11
+ runMcpServer(options: {
12
+ extended?: boolean;
13
+ includeOnly?: string;
14
+ includeAdditional?: string;
15
+ exclude?: string;
16
+ }): Promise<void>;
17
+ private processSubCommands;
18
+ private runBit;
19
+ static slots: never[];
20
+ static dependencies: import("@teambit/harmony").Aspect[];
21
+ static runtime: import("@teambit/harmony").RuntimeDefinition;
22
+ static provider([cli, loggerMain]: [CLIMain, LoggerMain]): Promise<CliMcpServerMain>;
23
+ }
24
+ export default CliMcpServerMain;
@@ -0,0 +1,269 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.CliMcpServerMain = void 0;
7
+ function _cli() {
8
+ const data = require("@teambit/cli");
9
+ _cli = function () {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ function _child_process() {
15
+ const data = _interopRequireDefault(require("child_process"));
16
+ _child_process = function () {
17
+ return data;
18
+ };
19
+ return data;
20
+ }
21
+ function _cliMcpServer() {
22
+ const data = require("./cli-mcp-server.aspect");
23
+ _cliMcpServer = function () {
24
+ return data;
25
+ };
26
+ return data;
27
+ }
28
+ function _mcpServer() {
29
+ const data = require("./mcp-server.cmd");
30
+ _mcpServer = function () {
31
+ return data;
32
+ };
33
+ return data;
34
+ }
35
+ function _mcp() {
36
+ const data = require("@modelcontextprotocol/sdk/server/mcp.js");
37
+ _mcp = function () {
38
+ return data;
39
+ };
40
+ return data;
41
+ }
42
+ function _stdio() {
43
+ const data = require("@modelcontextprotocol/sdk/server/stdio.js");
44
+ _stdio = function () {
45
+ return data;
46
+ };
47
+ return data;
48
+ }
49
+ function _zod() {
50
+ const data = require("zod");
51
+ _zod = function () {
52
+ return data;
53
+ };
54
+ return data;
55
+ }
56
+ function _logger() {
57
+ const data = require("@teambit/logger");
58
+ _logger = function () {
59
+ return data;
60
+ };
61
+ return data;
62
+ }
63
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
64
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
65
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
66
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /* eslint-disable import/extensions */ /* eslint-disable import/no-unresolved */
67
+ class CliMcpServerMain {
68
+ constructor(cli, logger) {
69
+ this.cli = cli;
70
+ this.logger = logger;
71
+ }
72
+ shouldIncludeCommand(cmdName, options) {
73
+ // Always exclude certain commands
74
+ if (options.alwaysExcludeTools.has(cmdName)) return false;
75
+
76
+ // User-specified exclude takes precedence
77
+ if (options.userExcludeSet?.has(cmdName)) {
78
+ this.logger.debug(`[MCP-DEBUG] Excluding command due to --exclude flag: ${cmdName}`);
79
+ return false;
80
+ }
81
+
82
+ // If includeOnly is specified, only include those specific commands
83
+ if (options.includeOnlySet) {
84
+ const shouldInclude = options.includeOnlySet.has(cmdName);
85
+ if (shouldInclude) {
86
+ this.logger.debug(`[MCP-DEBUG] Including command due to --include-only flag: ${cmdName}`);
87
+ }
88
+ return shouldInclude;
89
+ }
90
+
91
+ // Extended mode includes all commands except excluded ones
92
+ if (options.extended) return true;
93
+
94
+ // Default mode: include default tools + any additional specified
95
+ return options.defaultTools.has(cmdName) || (options.additionalCommandsSet?.has(cmdName) ?? false);
96
+ }
97
+ buildZodSchema(config) {
98
+ const schema = {
99
+ // Add cwd parameter as mandatory to all commands
100
+ cwd: _zod().z.string().describe('Path to workspace')
101
+ };
102
+ config.argsData.forEach(arg => {
103
+ const desc = arg.description || `Positional argument: ${arg.nameRaw}`;
104
+ if (arg.isArray) {
105
+ schema[arg.nameCamelCase] = arg.required ? _zod().z.array(_zod().z.string()).describe(desc) : _zod().z.array(_zod().z.string()).optional().describe(desc);
106
+ } else {
107
+ schema[arg.nameCamelCase] = arg.required ? _zod().z.string().describe(desc) : _zod().z.string().optional().describe(desc);
108
+ }
109
+ });
110
+ config.flagsData.forEach(flag => {
111
+ const type = flag.type;
112
+ schema[flag.name] = type === 'string' ? _zod().z.string().optional().describe(flag.description) : _zod().z.boolean().optional().describe(flag.description);
113
+ });
114
+ return schema;
115
+ }
116
+ buildCommandArgs(config, params) {
117
+ // Split the command name on spaces to properly handle subcommands
118
+ const args = config.name.split(' ');
119
+
120
+ // Add positional arguments in order
121
+ config.argsData.forEach(arg => {
122
+ const val = params[arg.nameCamelCase];
123
+ if (val === undefined) return;
124
+ if (arg.isArray && Array.isArray(val)) {
125
+ val.forEach(item => args.push(item));
126
+ } else {
127
+ args.push(val);
128
+ }
129
+ });
130
+
131
+ // Add options as flags
132
+ config.flagsData.forEach(flag => {
133
+ const name = flag.name;
134
+ const type = flag.type;
135
+ const val = params[name];
136
+ if (val === undefined) return;
137
+ if (type === 'boolean' && val) {
138
+ args.push(`--${name}`);
139
+ } else if (type === 'string' && val) {
140
+ // Check if the string value contains spaces and quote it if necessary
141
+ const stringValue = String(val);
142
+ if (stringValue.includes(' ')) {
143
+ args.push(`--${name}`, `"${stringValue}"`);
144
+ } else {
145
+ args.push(`--${name}`, stringValue);
146
+ }
147
+ }
148
+ });
149
+ return args;
150
+ }
151
+ registerToolForCommand(server, cmd, parentCmd) {
152
+ const cmdName = parentCmd ? `${(0, _cli().getCommandName)(parentCmd)} ${(0, _cli().getCommandName)(cmd)}` : (0, _cli().getCommandName)(cmd);
153
+
154
+ // replace white spaces (\s) and dashes (-) with underscores (_)
155
+ const toolName = `bit_${cmdName}`.replace(/[-\s]/g, '_');
156
+ const description = `${cmd.description}${cmd.extendedDescription ? `.\n(${cmd.extendedDescription})` : ''}`;
157
+ const config = {
158
+ name: cmdName,
159
+ description,
160
+ argsData: (0, _cli().getArgsData)(cmd),
161
+ flagsData: (0, _cli().getFlagsData)(cmd)
162
+ };
163
+ const schema = this.buildZodSchema(config);
164
+ server.tool(toolName, config.description, schema, async params => {
165
+ const argsToRun = this.buildCommandArgs(config, params);
166
+ return this.runBit(argsToRun, params.cwd);
167
+ });
168
+ }
169
+ async runMcpServer(options) {
170
+ this.logger.debug(`[MCP-DEBUG] Starting MCP server with options: ${JSON.stringify(options)}`);
171
+ const commands = this.cli.commands;
172
+ const extended = Boolean(options.extended);
173
+
174
+ // Default set of tools to include
175
+ const defaultTools = new Set(['status', 'list', 'add', 'init', 'show', 'tag', 'snap', 'import', 'export', 'remove', 'log', 'test', 'diff', 'install', 'lane show', 'lane create', 'lane switch', 'lane merge', 'create', 'templates', 'reset', 'checkout']);
176
+
177
+ // Tools to always exclude
178
+ const alwaysExcludeTools = new Set(['login', 'logout', 'completion', 'mcp-server', 'start', 'run-action', 'watch', 'run', 'resume-export', 'server', 'serve-preview']);
179
+
180
+ // Parse command strings from flag options
181
+ let includeOnlySet;
182
+ if (options.includeOnly) {
183
+ includeOnlySet = new Set(options.includeOnly.split(',').map(cmd => cmd.trim()));
184
+ this.logger.debug(`[MCP-DEBUG] Including only commands: ${Array.from(includeOnlySet).join(', ')}`);
185
+ }
186
+ let additionalCommandsSet;
187
+ if (options.includeAdditional) {
188
+ additionalCommandsSet = new Set(options.includeAdditional.split(',').map(cmd => cmd.trim()));
189
+ this.logger.debug(`[MCP-DEBUG] Including additional commands: ${Array.from(additionalCommandsSet).join(', ')}`);
190
+ }
191
+ let userExcludeSet;
192
+ if (options.exclude) {
193
+ userExcludeSet = new Set(options.exclude.split(',').map(cmd => cmd.trim()));
194
+ this.logger.debug(`[MCP-DEBUG] Excluding commands: ${Array.from(userExcludeSet).join(', ')}`);
195
+ }
196
+ const server = new (_mcp().McpServer)({
197
+ name: 'bit-cli-mcp',
198
+ version: '0.0.1'
199
+ });
200
+ const filterOptions = {
201
+ defaultTools,
202
+ additionalCommandsSet,
203
+ userExcludeSet,
204
+ alwaysExcludeTools,
205
+ extended,
206
+ includeOnlySet
207
+ };
208
+ commands.forEach(cmd => {
209
+ const cmdName = (0, _cli().getCommandName)(cmd);
210
+ if (this.shouldIncludeCommand(cmdName, filterOptions)) {
211
+ this.registerToolForCommand(server, cmd);
212
+ }
213
+
214
+ // Process sub-commands
215
+ if (cmd.commands && cmd.commands.length) {
216
+ this.processSubCommands(server, cmd, filterOptions);
217
+ }
218
+ });
219
+ await server.connect(new (_stdio().StdioServerTransport)());
220
+ }
221
+ processSubCommands(server, parentCmd, options) {
222
+ const parentCmdName = (0, _cli().getCommandName)(parentCmd);
223
+ parentCmd.commands?.forEach(subCmd => {
224
+ const subCmdName = (0, _cli().getCommandName)(subCmd);
225
+ const fullCmdName = `${parentCmdName} ${subCmdName}`;
226
+ if (this.shouldIncludeCommand(fullCmdName, options)) {
227
+ this.registerToolForCommand(server, subCmd, parentCmd);
228
+ }
229
+ });
230
+ }
231
+ async runBit(args, cwd) {
232
+ this.logger.debug(`[MCP-DEBUG] Running: bit ${args.join(' ')} in ${cwd}`);
233
+ const cmd = `bit ${args.join(' ')}`;
234
+ try {
235
+ const cmdOutput = _child_process().default.execSync(cmd, {
236
+ cwd
237
+ });
238
+ this.logger.debug(`[MCP-DEBUG] result. stdout: ${cmdOutput}`);
239
+ return {
240
+ content: [{
241
+ type: 'text',
242
+ text: cmdOutput.toString()
243
+ }]
244
+ };
245
+ } catch (error) {
246
+ this.logger.error(`[MCP-DEBUG] Error executing ${cmd}`, error);
247
+ return {
248
+ content: [{
249
+ type: 'text',
250
+ text: error.message
251
+ }]
252
+ };
253
+ }
254
+ }
255
+ static async provider([cli, loggerMain]) {
256
+ const logger = loggerMain.createLogger(_cliMcpServer().CliMcpServerAspect.id);
257
+ const mcpServer = new CliMcpServerMain(cli, logger);
258
+ cli.register(new (_mcpServer().McpServerCmd)(mcpServer));
259
+ return mcpServer;
260
+ }
261
+ }
262
+ exports.CliMcpServerMain = CliMcpServerMain;
263
+ _defineProperty(CliMcpServerMain, "slots", []);
264
+ _defineProperty(CliMcpServerMain, "dependencies", [_cli().CLIAspect, _logger().LoggerAspect]);
265
+ _defineProperty(CliMcpServerMain, "runtime", _cli().MainRuntime);
266
+ _cliMcpServer().CliMcpServerAspect.addRuntime(CliMcpServerMain);
267
+ var _default = exports.default = CliMcpServerMain;
268
+
269
+ //# sourceMappingURL=cli-mcp-server.main.runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_cli","data","require","_child_process","_interopRequireDefault","_cliMcpServer","_mcpServer","_mcp","_stdio","_zod","_logger","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","CliMcpServerMain","constructor","cli","logger","shouldIncludeCommand","cmdName","options","alwaysExcludeTools","has","userExcludeSet","debug","includeOnlySet","shouldInclude","extended","defaultTools","additionalCommandsSet","buildZodSchema","config","schema","cwd","z","string","describe","argsData","forEach","arg","desc","description","nameRaw","isArray","nameCamelCase","required","array","optional","flagsData","flag","type","name","boolean","buildCommandArgs","params","args","split","val","undefined","Array","item","push","stringValue","includes","registerToolForCommand","server","cmd","parentCmd","getCommandName","toolName","replace","extendedDescription","getArgsData","getFlagsData","tool","argsToRun","runBit","runMcpServer","JSON","stringify","commands","Boolean","Set","includeOnly","map","trim","from","join","includeAdditional","exclude","McpServer","version","filterOptions","length","processSubCommands","connect","StdioServerTransport","parentCmdName","subCmd","subCmdName","fullCmdName","cmdOutput","childProcess","execSync","content","text","toString","error","message","provider","loggerMain","createLogger","CliMcpServerAspect","id","mcpServer","register","McpServerCmd","exports","CLIAspect","LoggerAspect","MainRuntime","addRuntime","_default"],"sources":["cli-mcp-server.main.runtime.ts"],"sourcesContent":["/* eslint-disable import/extensions */\n/* eslint-disable import/no-unresolved */\n\nimport { CLIAspect, CLIMain, Command, getArgsData, getCommandName, getFlagsData, MainRuntime } from '@teambit/cli';\nimport childProcess from 'child_process';\nimport { CliMcpServerAspect } from './cli-mcp-server.aspect';\nimport { McpServerCmd } from './mcp-server.cmd';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport { CallToolResult } from '@modelcontextprotocol/sdk/types.js';\nimport { z } from 'zod';\nimport { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';\n\ninterface CommandFilterOptions {\n defaultTools: Set<string>;\n additionalCommandsSet?: Set<string>;\n userExcludeSet?: Set<string>;\n alwaysExcludeTools: Set<string>;\n extended: boolean;\n includeOnlySet?: Set<string>;\n}\n\ninterface CommandConfig {\n name: string;\n description: string;\n argsData: ReturnType<typeof getArgsData>;\n flagsData: ReturnType<typeof getFlagsData>;\n}\n\nexport class CliMcpServerMain {\n constructor(\n private cli: CLIMain,\n private logger: Logger\n ) {}\n\n private shouldIncludeCommand(cmdName: string, options: CommandFilterOptions): boolean {\n // Always exclude certain commands\n if (options.alwaysExcludeTools.has(cmdName)) return false;\n\n // User-specified exclude takes precedence\n if (options.userExcludeSet?.has(cmdName)) {\n this.logger.debug(`[MCP-DEBUG] Excluding command due to --exclude flag: ${cmdName}`);\n return false;\n }\n\n // If includeOnly is specified, only include those specific commands\n if (options.includeOnlySet) {\n const shouldInclude = options.includeOnlySet.has(cmdName);\n if (shouldInclude) {\n this.logger.debug(`[MCP-DEBUG] Including command due to --include-only flag: ${cmdName}`);\n }\n return shouldInclude;\n }\n\n // Extended mode includes all commands except excluded ones\n if (options.extended) return true;\n\n // Default mode: include default tools + any additional specified\n return options.defaultTools.has(cmdName) || (options.additionalCommandsSet?.has(cmdName) ?? false);\n }\n\n private buildZodSchema(config: CommandConfig): Record<string, any> {\n const schema: Record<string, any> = {\n // Add cwd parameter as mandatory to all commands\n cwd: z.string().describe('Path to workspace'),\n };\n\n config.argsData.forEach((arg) => {\n const desc = arg.description || `Positional argument: ${arg.nameRaw}`;\n if (arg.isArray) {\n schema[arg.nameCamelCase] = arg.required\n ? z.array(z.string()).describe(desc)\n : z.array(z.string()).optional().describe(desc);\n } else {\n schema[arg.nameCamelCase] = arg.required ? z.string().describe(desc) : z.string().optional().describe(desc);\n }\n });\n\n config.flagsData.forEach((flag) => {\n const type = flag.type;\n schema[flag.name] =\n type === 'string'\n ? z.string().optional().describe(flag.description)\n : z.boolean().optional().describe(flag.description);\n });\n\n return schema;\n }\n\n private buildCommandArgs(config: CommandConfig, params: any): string[] {\n // Split the command name on spaces to properly handle subcommands\n const args: string[] = config.name.split(' ');\n\n // Add positional arguments in order\n config.argsData.forEach((arg) => {\n const val = params[arg.nameCamelCase];\n if (val === undefined) return;\n\n if (arg.isArray && Array.isArray(val)) {\n val.forEach((item) => args.push(item));\n } else {\n args.push(val);\n }\n });\n\n // Add options as flags\n config.flagsData.forEach((flag) => {\n const name = flag.name;\n const type = flag.type;\n const val = params[name];\n if (val === undefined) return;\n if (type === 'boolean' && val) {\n args.push(`--${name}`);\n } else if (type === 'string' && val) {\n // Check if the string value contains spaces and quote it if necessary\n const stringValue = String(val);\n if (stringValue.includes(' ')) {\n args.push(`--${name}`, `\"${stringValue}\"`);\n } else {\n args.push(`--${name}`, stringValue);\n }\n }\n });\n\n return args;\n }\n\n private registerToolForCommand(server: McpServer, cmd: Command, parentCmd?: Command) {\n const cmdName = parentCmd ? `${getCommandName(parentCmd)} ${getCommandName(cmd)}` : getCommandName(cmd);\n\n // replace white spaces (\\s) and dashes (-) with underscores (_)\n const toolName = `bit_${cmdName}`.replace(/[-\\s]/g, '_');\n const description = `${cmd.description}${cmd.extendedDescription ? `.\\n(${cmd.extendedDescription})` : ''}`;\n const config: CommandConfig = {\n name: cmdName,\n description,\n argsData: getArgsData(cmd),\n flagsData: getFlagsData(cmd),\n };\n\n const schema = this.buildZodSchema(config);\n\n server.tool(toolName, config.description, schema, async (params: any) => {\n const argsToRun = this.buildCommandArgs(config, params);\n return this.runBit(argsToRun, params.cwd);\n });\n }\n\n async runMcpServer(options: {\n extended?: boolean;\n includeOnly?: string;\n includeAdditional?: string;\n exclude?: string;\n }) {\n this.logger.debug(`[MCP-DEBUG] Starting MCP server with options: ${JSON.stringify(options)}`);\n const commands = this.cli.commands;\n const extended = Boolean(options.extended);\n\n // Default set of tools to include\n const defaultTools = new Set([\n 'status',\n 'list',\n 'add',\n 'init',\n 'show',\n 'tag',\n 'snap',\n 'import',\n 'export',\n 'remove',\n 'log',\n 'test',\n 'diff',\n 'install',\n 'lane show',\n 'lane create',\n 'lane switch',\n 'lane merge',\n 'create',\n 'templates',\n 'reset',\n 'checkout',\n ]);\n\n // Tools to always exclude\n const alwaysExcludeTools = new Set([\n 'login',\n 'logout',\n 'completion',\n 'mcp-server',\n 'start',\n 'run-action',\n 'watch',\n 'run',\n 'resume-export',\n 'server',\n 'serve-preview',\n ]);\n\n // Parse command strings from flag options\n let includeOnlySet: Set<string> | undefined;\n if (options.includeOnly) {\n includeOnlySet = new Set(options.includeOnly.split(',').map((cmd) => cmd.trim()));\n this.logger.debug(`[MCP-DEBUG] Including only commands: ${Array.from(includeOnlySet).join(', ')}`);\n }\n\n let additionalCommandsSet: Set<string> | undefined;\n if (options.includeAdditional) {\n additionalCommandsSet = new Set(options.includeAdditional.split(',').map((cmd) => cmd.trim()));\n this.logger.debug(`[MCP-DEBUG] Including additional commands: ${Array.from(additionalCommandsSet).join(', ')}`);\n }\n\n let userExcludeSet: Set<string> | undefined;\n if (options.exclude) {\n userExcludeSet = new Set(options.exclude.split(',').map((cmd) => cmd.trim()));\n this.logger.debug(`[MCP-DEBUG] Excluding commands: ${Array.from(userExcludeSet).join(', ')}`);\n }\n\n const server = new McpServer({\n name: 'bit-cli-mcp',\n version: '0.0.1',\n });\n\n const filterOptions: CommandFilterOptions = {\n defaultTools,\n additionalCommandsSet,\n userExcludeSet,\n alwaysExcludeTools,\n extended,\n includeOnlySet,\n };\n\n commands.forEach((cmd) => {\n const cmdName = getCommandName(cmd);\n\n if (this.shouldIncludeCommand(cmdName, filterOptions)) {\n this.registerToolForCommand(server, cmd);\n }\n\n // Process sub-commands\n if (cmd.commands && cmd.commands.length) {\n this.processSubCommands(server, cmd, filterOptions);\n }\n });\n\n await server.connect(new StdioServerTransport());\n }\n\n private processSubCommands(server: McpServer, parentCmd: Command, options: CommandFilterOptions) {\n const parentCmdName = getCommandName(parentCmd);\n\n parentCmd.commands?.forEach((subCmd) => {\n const subCmdName = getCommandName(subCmd);\n const fullCmdName = `${parentCmdName} ${subCmdName}`;\n\n if (this.shouldIncludeCommand(fullCmdName, options)) {\n this.registerToolForCommand(server, subCmd, parentCmd);\n }\n });\n }\n\n private async runBit(args: string[], cwd: string): Promise<CallToolResult> {\n this.logger.debug(`[MCP-DEBUG] Running: bit ${args.join(' ')} in ${cwd}`);\n const cmd = `bit ${args.join(' ')}`;\n try {\n const cmdOutput = childProcess.execSync(cmd, { cwd });\n this.logger.debug(`[MCP-DEBUG] result. stdout: ${cmdOutput}`);\n\n return { content: [{ type: 'text', text: cmdOutput.toString() }] };\n } catch (error: any) {\n this.logger.error(`[MCP-DEBUG] Error executing ${cmd}`, error);\n\n return { content: [{ type: 'text', text: error.message }] };\n }\n }\n\n static slots = [];\n static dependencies = [CLIAspect, LoggerAspect];\n static runtime = MainRuntime;\n static async provider([cli, loggerMain]: [CLIMain, LoggerMain]) {\n const logger = loggerMain.createLogger(CliMcpServerAspect.id);\n const mcpServer = new CliMcpServerMain(cli, logger);\n cli.register(new McpServerCmd(mcpServer));\n return mcpServer;\n }\n}\n\nCliMcpServerAspect.addRuntime(CliMcpServerMain);\n\nexport default CliMcpServerMain;\n"],"mappings":";;;;;;AAGA,SAAAA,KAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,IAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAA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time';
3
+ export default CliMcpServerAspect;
4
+ export { CliMcpServerAspect };
package/dist/index.js ADDED
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "CliMcpServerAspect", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _cliMcpServer().CliMcpServerAspect;
10
+ }
11
+ });
12
+ exports.default = void 0;
13
+ function _cliMcpServer() {
14
+ const data = require("./cli-mcp-server.aspect");
15
+ _cliMcpServer = function () {
16
+ return data;
17
+ };
18
+ return data;
19
+ }
20
+ var _default = exports.default = _cliMcpServer().CliMcpServerAspect;
21
+
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_cliMcpServer","data","require","_default","exports","default","CliMcpServerAspect"],"sources":["index.ts"],"sourcesContent":["import { CliMcpServerAspect } from './cli-mcp-server.aspect';\n\nexport type { CliMcpServerMain } from './cli-mcp-server.main.runtime';\nexport default CliMcpServerAspect;\nexport { CliMcpServerAspect };\n"],"mappings":";;;;;;;;;;;;AAAA,SAAAA,cAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,aAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA6D,IAAAE,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAG9CC,kCAAkB","ignoreList":[]}
@@ -0,0 +1,19 @@
1
+ import { CLIArgs, Command, CommandOptions } from '@teambit/cli';
2
+ import { CliMcpServerMain } from './cli-mcp-server.main.runtime';
3
+ export type McpServerCmdOptions = {
4
+ extended?: boolean;
5
+ includeOnly?: string;
6
+ includeAdditional?: string;
7
+ exclude?: string;
8
+ };
9
+ export declare class McpServerCmd implements Command {
10
+ private mcpServer;
11
+ name: string;
12
+ description: string;
13
+ alias: string;
14
+ group: string;
15
+ loader: boolean;
16
+ options: CommandOptions;
17
+ constructor(mcpServer: CliMcpServerMain);
18
+ wait(args: CLIArgs, flags: McpServerCmdOptions): Promise<void>;
19
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.McpServerCmd = void 0;
7
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
8
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
9
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
10
+ class McpServerCmd {
11
+ constructor(mcpServer) {
12
+ this.mcpServer = mcpServer;
13
+ _defineProperty(this, "name", 'mcp-server');
14
+ _defineProperty(this, "description", 'Start the Bit CLI Model Context Protocol (MCP) server for programmatic and remote access to Bit commands.');
15
+ _defineProperty(this, "alias", '');
16
+ _defineProperty(this, "group", 'development');
17
+ _defineProperty(this, "loader", false);
18
+ _defineProperty(this, "options", [['e', 'extended', 'Enable the full set of Bit CLI commands as MCP tools'], ['', 'include-only <commands>', 'Specify a subset of commands to expose as MCP tools. Use comma-separated list in quotes, e.g. "status,install,compile"'], ['', 'include-additional <commands>', 'Add specific commands to the default MCP tools set. Use comma-separated list in quotes. Only applies when --extended is not used'], ['', 'exclude <commands>', 'Prevent specific commands from being exposed as MCP tools. Use comma-separated list in quotes']]);
19
+ }
20
+ async wait(args, flags) {
21
+ await this.mcpServer.runMcpServer(flags);
22
+ }
23
+ }
24
+ exports.McpServerCmd = McpServerCmd;
25
+
26
+ //# sourceMappingURL=mcp-server.cmd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["McpServerCmd","constructor","mcpServer","_defineProperty","wait","args","flags","runMcpServer","exports"],"sources":["mcp-server.cmd.ts"],"sourcesContent":["import { CLIArgs, Command, CommandOptions } from '@teambit/cli';\nimport { CliMcpServerMain } from './cli-mcp-server.main.runtime';\n\nexport type McpServerCmdOptions = {\n extended?: boolean;\n includeOnly?: string;\n includeAdditional?: string;\n exclude?: string;\n};\n\nexport class McpServerCmd implements Command {\n name = 'mcp-server';\n description = 'Start the Bit CLI Model Context Protocol (MCP) server for programmatic and remote access to Bit commands.';\n alias = '';\n group = 'development';\n loader = false;\n options = [\n ['e', 'extended', 'Enable the full set of Bit CLI commands as MCP tools'],\n ['' , 'include-only <commands>', 'Specify a subset of commands to expose as MCP tools. Use comma-separated list in quotes, e.g. \"status,install,compile\"'],\n ['', 'include-additional <commands>', 'Add specific commands to the default MCP tools set. Use comma-separated list in quotes. Only applies when --extended is not used'],\n ['', 'exclude <commands>', 'Prevent specific commands from being exposed as MCP tools. Use comma-separated list in quotes'],\n ] as CommandOptions;\n\n constructor(\n private mcpServer: CliMcpServerMain\n ) {}\n\n async wait(args: CLIArgs, flags: McpServerCmdOptions): Promise<void> {\n await this.mcpServer.runMcpServer(flags);\n }\n}\n"],"mappings":";;;;;;;;;AAUO,MAAMA,YAAY,CAAoB;EAa3CC,WAAWA,CACDC,SAA2B,EACnC;IAAA,KADQA,SAA2B,GAA3BA,SAA2B;IAAAC,eAAA,eAb9B,YAAY;IAAAA,eAAA,sBACL,2GAA2G;IAAAA,eAAA,gBACjH,EAAE;IAAAA,eAAA,gBACF,aAAa;IAAAA,eAAA,iBACZ,KAAK;IAAAA,eAAA,kBACJ,CACR,CAAC,GAAG,EAAE,UAAU,EAAE,sDAAsD,CAAC,EACzE,CAAC,EAAE,EAAG,yBAAyB,EAAE,wHAAwH,CAAC,EAC1J,CAAC,EAAE,EAAE,+BAA+B,EAAE,kIAAkI,CAAC,EACzK,CAAC,EAAE,EAAE,oBAAoB,EAAE,+FAA+F,CAAC,CAC5H;EAIE;EAEH,MAAMC,IAAIA,CAACC,IAAa,EAAEC,KAA0B,EAAiB;IACnE,MAAM,IAAI,CAACJ,SAAS,CAACK,YAAY,CAACD,KAAK,CAAC;EAC1C;AACF;AAACE,OAAA,CAAAR,YAAA,GAAAA,YAAA","ignoreList":[]}
@@ -0,0 +1,7 @@
1
+ ;
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.mcp_cli-mcp-server@0.0.1/dist/README.docs.mdx';
3
+
4
+ export const compositions = [];
5
+ export const overview = [overview_0];
6
+
7
+ export const compositions_metadata = {"compositions":[]};
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@teambit/cli-mcp-server",
3
+ "version": "0.0.1",
4
+ "main": "dist/index.js",
5
+ "componentId": {
6
+ "name": "cli-mcp-server",
7
+ "version": "0.0.1",
8
+ "scope": "teambit.mcp"
9
+ },
10
+ "dependencies": {
11
+ "zod": "^3.24.4",
12
+ "@modelcontextprotocol/sdk": "^1.11.0",
13
+ "@teambit/harmony": "0.4.7",
14
+ "@teambit/cli": "0.0.1194",
15
+ "@teambit/logger": "0.0.1287"
16
+ },
17
+ "devDependencies": {
18
+ "@teambit/harmony.envs.core-aspect-env": "0.0.69"
19
+ },
20
+ "peerDependencies": {},
21
+ "license": "Apache-2.0",
22
+ "optionalDependencies": {},
23
+ "peerDependenciesMeta": {},
24
+ "exports": {
25
+ ".": {
26
+ "node": {
27
+ "require": "./dist/index.js",
28
+ "import": "./dist/esm.mjs"
29
+ },
30
+ "default": "./dist/index.js"
31
+ },
32
+ "./dist/*": "./dist/*",
33
+ "./artifacts/*": "./artifacts/*",
34
+ "./*": "./*.ts"
35
+ },
36
+ "private": false,
37
+ "engines": {
38
+ "node": ">=16.0.0"
39
+ },
40
+ "repository": {
41
+ "type": "git",
42
+ "url": "https://github.com/teambit/bit"
43
+ },
44
+ "keywords": [
45
+ "bit",
46
+ "bit-aspect",
47
+ "bit-core-aspect",
48
+ "components",
49
+ "collaboration",
50
+ "web"
51
+ ]
52
+ }
@@ -0,0 +1,41 @@
1
+ declare module '*.png' {
2
+ const value: any;
3
+ export = value;
4
+ }
5
+ declare module '*.svg' {
6
+ import type { FunctionComponent, SVGProps } from 'react';
7
+
8
+ export const ReactComponent: FunctionComponent<
9
+ SVGProps<SVGSVGElement> & { title?: string }
10
+ >;
11
+ const src: string;
12
+ export default src;
13
+ }
14
+ declare module '*.jpg' {
15
+ const value: any;
16
+ export = value;
17
+ }
18
+ declare module '*.jpeg' {
19
+ const value: any;
20
+ export = value;
21
+ }
22
+ declare module '*.gif' {
23
+ const value: any;
24
+ export = value;
25
+ }
26
+ declare module '*.bmp' {
27
+ const value: any;
28
+ export = value;
29
+ }
30
+ declare module '*.otf' {
31
+ const value: any;
32
+ export = value;
33
+ }
34
+ declare module '*.woff' {
35
+ const value: any;
36
+ export = value;
37
+ }
38
+ declare module '*.woff2' {
39
+ const value: any;
40
+ export = value;
41
+ }
@@ -0,0 +1,42 @@
1
+ declare module '*.module.css' {
2
+ const classes: { readonly [key: string]: string };
3
+ export default classes;
4
+ }
5
+ declare module '*.module.scss' {
6
+ const classes: { readonly [key: string]: string };
7
+ export default classes;
8
+ }
9
+ declare module '*.module.sass' {
10
+ const classes: { readonly [key: string]: string };
11
+ export default classes;
12
+ }
13
+
14
+ declare module '*.module.less' {
15
+ const classes: { readonly [key: string]: string };
16
+ export default classes;
17
+ }
18
+
19
+ declare module '*.less' {
20
+ const classes: { readonly [key: string]: string };
21
+ export default classes;
22
+ }
23
+
24
+ declare module '*.css' {
25
+ const classes: { readonly [key: string]: string };
26
+ export default classes;
27
+ }
28
+
29
+ declare module '*.sass' {
30
+ const classes: { readonly [key: string]: string };
31
+ export default classes;
32
+ }
33
+
34
+ declare module '*.scss' {
35
+ const classes: { readonly [key: string]: string };
36
+ export default classes;
37
+ }
38
+
39
+ declare module '*.mdx' {
40
+ const component: any;
41
+ export default component;
42
+ }