@node-in-layers/core-knowledge-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.
Files changed (50) hide show
  1. package/README.md +7 -0
  2. package/bin/build.sh +30 -0
  3. package/bin/mcp_server.js +29 -0
  4. package/bin/shell.mts +77 -0
  5. package/config.prod.mjs +61 -0
  6. package/dist/README.md +7 -0
  7. package/dist/bin/mcp_server.js +29 -0
  8. package/dist/bin/shell.mts +77 -0
  9. package/dist/config.prod.mjs +61 -0
  10. package/dist/knowledge/entries.json +215 -0
  11. package/dist/knowledge/features.d.ts +3 -0
  12. package/dist/knowledge/features.js +23 -0
  13. package/dist/knowledge/features.js.map +1 -0
  14. package/dist/knowledge/index.d.ts +5 -0
  15. package/dist/knowledge/index.js +6 -0
  16. package/dist/knowledge/index.js.map +1 -0
  17. package/dist/knowledge/mcp.d.ts +5 -0
  18. package/dist/knowledge/mcp.js +5 -0
  19. package/dist/knowledge/mcp.js.map +1 -0
  20. package/dist/knowledge/services.d.ts +3 -0
  21. package/dist/knowledge/services.js +5 -0
  22. package/dist/knowledge/services.js.map +1 -0
  23. package/dist/knowledge/types.d.ts +30 -0
  24. package/dist/knowledge/types.js +9 -0
  25. package/dist/knowledge/types.js.map +1 -0
  26. package/dist/mcp/index.d.ts +3 -0
  27. package/dist/mcp/index.js +4 -0
  28. package/dist/mcp/index.js.map +1 -0
  29. package/dist/mcp/mcp.d.ts +2 -0
  30. package/dist/mcp/mcp.js +42 -0
  31. package/dist/mcp/mcp.js.map +1 -0
  32. package/dist/mcp/types.d.ts +17 -0
  33. package/dist/mcp/types.js +2 -0
  34. package/dist/mcp/types.js.map +1 -0
  35. package/dist/package.json +61 -0
  36. package/dist/types.d.ts +8 -0
  37. package/dist/types.js +2 -0
  38. package/dist/types.js.map +1 -0
  39. package/package.json +61 -0
  40. package/src/knowledge/entries.json +215 -0
  41. package/src/knowledge/features.ts +47 -0
  42. package/src/knowledge/index.ts +6 -0
  43. package/src/knowledge/mcp.ts +11 -0
  44. package/src/knowledge/services.ts +8 -0
  45. package/src/knowledge/types.ts +43 -0
  46. package/src/mcp/index.ts +4 -0
  47. package/src/mcp/mcp.ts +56 -0
  48. package/src/mcp/types.ts +25 -0
  49. package/src/types.ts +9 -0
  50. package/tsconfig.json +27 -0
package/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # Development Mcp Tool for Node in Layers Core
2
+ Whenever you build a system using node in layers core, you can use this MCP tool to teach the AI how to actually interact and work with your node in layers system.
3
+
4
+ ## How To Use
5
+ ```bash
6
+ npx install @node-in-layers/core-knowledge-mcp
7
+ ```
package/bin/build.sh ADDED
@@ -0,0 +1,30 @@
1
+ #!/bin/bash
2
+ set -e
3
+
4
+ # Build parent core package so we can embed it
5
+ npm --prefix .. run build
6
+
7
+ rm -Rf ./dist
8
+
9
+ # Bundle built core into local node_modules for runtime self-containment
10
+ rm -Rf ./node_modules/@node-in-layers/core
11
+ mkdir -p ./node_modules/@node-in-layers/core
12
+ cp -R ../dist/* ./node_modules/@node-in-layers/core/
13
+
14
+ npm run tsc -- -p ./tsconfig.json
15
+ node - <<'NODE'
16
+ const fs = require('fs');
17
+ const corePkg = JSON.parse(fs.readFileSync('../package.json','utf8'));
18
+ const mcpPkg = JSON.parse(fs.readFileSync('./package.json','utf8'));
19
+ mcpPkg.version = corePkg.version;
20
+ mcpPkg.dependencies = mcpPkg.dependencies || {};
21
+ mcpPkg.dependencies['@node-in-layers/core'] = corePkg.version;
22
+ fs.mkdirSync('./dist', { recursive: true });
23
+ fs.writeFileSync('./dist/package.json', JSON.stringify(mcpPkg, null, 2));
24
+ NODE
25
+ cp README.md ./dist
26
+ cp -R ./bin/ ./dist/
27
+ cp ./config.prod.mjs ./dist/
28
+ rm ./dist/bin/build.sh
29
+
30
+ sed -i -e 's/..\/dist\//..\//g' ./dist/bin/mcp_server.js
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env tsx
2
+
3
+ import esMain from 'es-main'
4
+ import { ArgumentParser } from 'argparse'
5
+ import * as core from '@node-in-layers/core'
6
+ import * as config from '../dist/config.prod.mjs'
7
+
8
+ const _parseArguments = () => {
9
+ const parser = new ArgumentParser({
10
+ description: 'Starts the MCP server.',
11
+ })
12
+ return parser.parse_args()
13
+ }
14
+
15
+ const startServer = async () => {
16
+ const context = (await core.loadSystem({
17
+ environment: 'prod',
18
+ config: config.default(),
19
+ }))
20
+ await context.mcp.mcp.start()
21
+ }
22
+
23
+ if (esMain(import.meta)) {
24
+ const args = _parseArguments()
25
+ startServer(args.environment).catch((error) => {
26
+ console.error('Failed to start the server:', error)
27
+ process.exit(1)
28
+ })
29
+ }
package/bin/shell.mts ADDED
@@ -0,0 +1,77 @@
1
+ #!/usr/bin/env tsx
2
+
3
+ import invoke from 'lodash/invoke.js'
4
+ import esMain from 'es-main'
5
+ import { ArgumentParser } from 'argparse'
6
+ import repl from 'repl'
7
+ import chalk from 'chalk'
8
+ import merge from 'lodash/merge.js'
9
+ import { queryBuilder } from 'functional-models'
10
+ import * as core from '@node-in-layers/core'
11
+ import { System } from '../src/types.js'
12
+
13
+ const _parseArguments = () => {
14
+ const parser = new ArgumentParser({
15
+ description: 'Starts a shell environment into the system.',
16
+ })
17
+ parser.add_argument('environment', {
18
+ help: 'The environment for the service.',
19
+ })
20
+ parser.add_argument('-c', '--command', {
21
+ help: 'A dot path command to run',
22
+ })
23
+ parser.add_argument('-d', '--data', {
24
+ help: 'Stringified JSON data to pass to the command',
25
+ })
26
+ return parser.parse_args()
27
+ }
28
+
29
+ const _systemStartup = async environment => {
30
+ return core.loadSystem({
31
+ environment,
32
+ }) as unknown as System
33
+ }
34
+
35
+ const help = objects => () => {
36
+ console.info(chalk.white.bold(`You have access to the following objects:`))
37
+ console.info(chalk.white.bold(`[${Object.keys(objects).join(', ')}]`))
38
+ console.info()
39
+ console.info(
40
+ chalk.white.bold('You can also write "help()" to see this again.')
41
+ )
42
+ }
43
+
44
+ const runCommand = async (objects, command, data) => {
45
+ return invoke(objects, command, data)
46
+ }
47
+
48
+ const main = async () => {
49
+ const args = _parseArguments()
50
+ const objects = { ...(await _systemStartup(args.environment)), queryBuilder }
51
+ process.on('SIGINT', async function () {
52
+ await objects.services['@node-in-layers/data'].cleanup()
53
+ process.exit()
54
+ })
55
+ if (args.command) {
56
+ const result = await runCommand(
57
+ objects,
58
+ args.command,
59
+ args.data ? JSON.parse(args.data) : []
60
+ )
61
+ console.info(result)
62
+ process.exit()
63
+ return
64
+ }
65
+ const context = repl.start().context
66
+ const toUse = merge({ context: objects }, objects)
67
+ merge(context, objects, toUse)
68
+ console.info(chalk.blue.bold(`Welcome to the shell.`))
69
+ console.info(chalk.blue.bold(`--------------------------------`))
70
+ const helpFunc = help(toUse)
71
+ helpFunc()
72
+ context.help = helpFunc
73
+ }
74
+
75
+ if (esMain(import.meta)) {
76
+ main()
77
+ }
@@ -0,0 +1,61 @@
1
+ import {
2
+ CoreNamespace,
3
+ LogFormat,
4
+ LogLevelNames,
5
+ } from '@node-in-layers/core'
6
+ import { McpNamespace } from '@node-in-layers/mcp-server'
7
+
8
+ export default async () => {
9
+ return {
10
+ environment: 'prod',
11
+ systemName: '@node-in-layers/core/knowledge-mcp',
12
+ [CoreNamespace.root]: {
13
+ // @ts-ignore
14
+ apps: await Promise.all([
15
+ import(`@node-in-layers/mcp-server/index.js`),
16
+ import('./mcp/index.js'),
17
+ import('./knowledge/index.js'),
18
+ ]),
19
+ layerOrder: ['services', 'features', ['entries', 'mcp']],
20
+ logging: {
21
+ logLevel: LogLevelNames.trace,
22
+ logFormat: LogFormat.json,
23
+ // @ts-ignore
24
+ //customLogger: createCustomLogger(),
25
+ ignoreLayerFunctions: {
26
+ 'amplify:services:getActiveGrowthAds': true,
27
+ 'mongo.services.getMongoCollection': true,
28
+ 'logs.features.searchRequests': true,
29
+ 'auth.features': true,
30
+ 'logging.services': true,
31
+ 'logging.features': true,
32
+ 'deepHelixAuth.services': true,
33
+ 'deepHelixAuth.features.authMiddleware': true,
34
+ 'mcp.mcp.addTool': true,
35
+ 'mcp.mcp.addUnprotectedRoute': true,
36
+ 'mcp.mcp.start': true,
37
+ 'mcp.mcp.addFeature': true,
38
+ '@node-in-layers/data.express': true,
39
+ '@node-in-layers/data.services': true,
40
+ '@node-in-layers/data.features': true,
41
+ '@node-in-layers/rest-api/express.express': true,
42
+ '@node-in-layers/rest-api/express.features': true,
43
+ '@node-in-layers/rest-api/express.services': true,
44
+ '@node-in-layers/mcp-server.mcp': true,
45
+ 'azure.services.discoverAzureStorageAccountAndKey': true,
46
+ 'tasks.features.runFeatureTask': true,
47
+ 'azure.express': true,
48
+ 'api.express': true,
49
+ },
50
+ },
51
+ },
52
+ [McpNamespace]: {
53
+ server: {
54
+ connection: {
55
+ // @ts-ignore
56
+ type: 'cli',
57
+ },
58
+ },
59
+ },
60
+ }
61
+ }
package/dist/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # Development Mcp Tool for Node in Layers Core
2
+ Whenever you build a system using node in layers core, you can use this MCP tool to teach the AI how to actually interact and work with your node in layers system.
3
+
4
+ ## How To Use
5
+ ```bash
6
+ npx install @node-in-layers/core-knowledge-mcp
7
+ ```
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env tsx
2
+
3
+ import esMain from 'es-main'
4
+ import { ArgumentParser } from 'argparse'
5
+ import * as core from '@node-in-layers/core'
6
+ import * as config from '../config.prod.mjs'
7
+
8
+ const _parseArguments = () => {
9
+ const parser = new ArgumentParser({
10
+ description: 'Starts the MCP server.',
11
+ })
12
+ return parser.parse_args()
13
+ }
14
+
15
+ const startServer = async () => {
16
+ const context = (await core.loadSystem({
17
+ environment: 'prod',
18
+ config: config.default(),
19
+ }))
20
+ await context.mcp.mcp.start()
21
+ }
22
+
23
+ if (esMain(import.meta)) {
24
+ const args = _parseArguments()
25
+ startServer(args.environment).catch((error) => {
26
+ console.error('Failed to start the server:', error)
27
+ process.exit(1)
28
+ })
29
+ }
@@ -0,0 +1,77 @@
1
+ #!/usr/bin/env tsx
2
+
3
+ import invoke from 'lodash/invoke.js'
4
+ import esMain from 'es-main'
5
+ import { ArgumentParser } from 'argparse'
6
+ import repl from 'repl'
7
+ import chalk from 'chalk'
8
+ import merge from 'lodash/merge.js'
9
+ import { queryBuilder } from 'functional-models'
10
+ import * as core from '@node-in-layers/core'
11
+ import { System } from '../src/types.js'
12
+
13
+ const _parseArguments = () => {
14
+ const parser = new ArgumentParser({
15
+ description: 'Starts a shell environment into the system.',
16
+ })
17
+ parser.add_argument('environment', {
18
+ help: 'The environment for the service.',
19
+ })
20
+ parser.add_argument('-c', '--command', {
21
+ help: 'A dot path command to run',
22
+ })
23
+ parser.add_argument('-d', '--data', {
24
+ help: 'Stringified JSON data to pass to the command',
25
+ })
26
+ return parser.parse_args()
27
+ }
28
+
29
+ const _systemStartup = async environment => {
30
+ return core.loadSystem({
31
+ environment,
32
+ }) as unknown as System
33
+ }
34
+
35
+ const help = objects => () => {
36
+ console.info(chalk.white.bold(`You have access to the following objects:`))
37
+ console.info(chalk.white.bold(`[${Object.keys(objects).join(', ')}]`))
38
+ console.info()
39
+ console.info(
40
+ chalk.white.bold('You can also write "help()" to see this again.')
41
+ )
42
+ }
43
+
44
+ const runCommand = async (objects, command, data) => {
45
+ return invoke(objects, command, data)
46
+ }
47
+
48
+ const main = async () => {
49
+ const args = _parseArguments()
50
+ const objects = { ...(await _systemStartup(args.environment)), queryBuilder }
51
+ process.on('SIGINT', async function () {
52
+ await objects.services['@node-in-layers/data'].cleanup()
53
+ process.exit()
54
+ })
55
+ if (args.command) {
56
+ const result = await runCommand(
57
+ objects,
58
+ args.command,
59
+ args.data ? JSON.parse(args.data) : []
60
+ )
61
+ console.info(result)
62
+ process.exit()
63
+ return
64
+ }
65
+ const context = repl.start().context
66
+ const toUse = merge({ context: objects }, objects)
67
+ merge(context, objects, toUse)
68
+ console.info(chalk.blue.bold(`Welcome to the shell.`))
69
+ console.info(chalk.blue.bold(`--------------------------------`))
70
+ const helpFunc = help(toUse)
71
+ helpFunc()
72
+ context.help = helpFunc
73
+ }
74
+
75
+ if (esMain(import.meta)) {
76
+ main()
77
+ }
@@ -0,0 +1,61 @@
1
+ import {
2
+ CoreNamespace,
3
+ LogFormat,
4
+ LogLevelNames,
5
+ } from '@node-in-layers/core'
6
+ import { McpNamespace } from '@node-in-layers/mcp-server'
7
+
8
+ export default async () => {
9
+ return {
10
+ environment: 'prod',
11
+ systemName: '@node-in-layers/core/knowledge-mcp',
12
+ [CoreNamespace.root]: {
13
+ // @ts-ignore
14
+ apps: await Promise.all([
15
+ import(`@node-in-layers/mcp-server/index.js`),
16
+ import('./mcp/index.js'),
17
+ import('./knowledge/index.js'),
18
+ ]),
19
+ layerOrder: ['services', 'features', ['entries', 'mcp']],
20
+ logging: {
21
+ logLevel: LogLevelNames.trace,
22
+ logFormat: LogFormat.json,
23
+ // @ts-ignore
24
+ //customLogger: createCustomLogger(),
25
+ ignoreLayerFunctions: {
26
+ 'amplify:services:getActiveGrowthAds': true,
27
+ 'mongo.services.getMongoCollection': true,
28
+ 'logs.features.searchRequests': true,
29
+ 'auth.features': true,
30
+ 'logging.services': true,
31
+ 'logging.features': true,
32
+ 'deepHelixAuth.services': true,
33
+ 'deepHelixAuth.features.authMiddleware': true,
34
+ 'mcp.mcp.addTool': true,
35
+ 'mcp.mcp.addUnprotectedRoute': true,
36
+ 'mcp.mcp.start': true,
37
+ 'mcp.mcp.addFeature': true,
38
+ '@node-in-layers/data.express': true,
39
+ '@node-in-layers/data.services': true,
40
+ '@node-in-layers/data.features': true,
41
+ '@node-in-layers/rest-api/express.express': true,
42
+ '@node-in-layers/rest-api/express.features': true,
43
+ '@node-in-layers/rest-api/express.services': true,
44
+ '@node-in-layers/mcp-server.mcp': true,
45
+ 'azure.services.discoverAzureStorageAccountAndKey': true,
46
+ 'tasks.features.runFeatureTask': true,
47
+ 'azure.express': true,
48
+ 'api.express': true,
49
+ },
50
+ },
51
+ },
52
+ [McpNamespace]: {
53
+ server: {
54
+ connection: {
55
+ // @ts-ignore
56
+ type: 'cli',
57
+ },
58
+ },
59
+ },
60
+ }
61
+ }