@node-in-layers/mcp-server 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/README.md ADDED
@@ -0,0 +1,149 @@
1
+ # MCP Server - A Node In Layers Package for building MCP Servers
2
+
3
+ This library adds the ability to easily create MCP servers with Node In Layers.
4
+
5
+ It has a companion library called '@node-in-layers/mcp-client' which is used for creating MCP clients. These two libraries share the same functions for defining models and tools.
6
+
7
+ ## New Layer
8
+
9
+ This library adds a new layer `mcp` to the system. It should be placed after the `express` layer.
10
+
11
+ ## Usage
12
+
13
+ In order to use this library, you must make additions to your config, as well as create and export "mcp" layers from your apps/domains.
14
+
15
+ ### Config
16
+
17
+ you add this app/domain to your config file. You should do this before your apps which will add tools to the MCP server.
18
+
19
+ You then configure the `mcp` app/domain with the following:
20
+
21
+ ```typescript
22
+ const mcpConfig = {
23
+ // (optional) The name of your MCP server.
24
+ name: 'mcp',
25
+ // (optional) The version of your MCP server.
26
+ version: '1.0.0',
27
+ // The server config from @l4t/mcp-ai/simple-server/types.js
28
+ server: {
29
+ connection: {
30
+ type: 'http',
31
+ host: 'localhost',
32
+ port: 3000,
33
+ },
34
+ },
35
+ logging: {
36
+ // optional
37
+ // If you want to change the default. Its 'info' by default.
38
+ requestLogLevel: 'info',
39
+ // If you want to change the default. Its 'info' by default.
40
+ responseLogLevel: 'info',
41
+ },
42
+ }
43
+
44
+ const config = {
45
+ ['@node-in-layers/mcp-server']: mcpConfig,
46
+ }
47
+ ```
48
+
49
+ ### Creating an MCP Layer
50
+
51
+ You can create an MCP layer by exporting a function from your app/domain that returns a layer.
52
+
53
+ ```typescript
54
+ // /src/yourDomain/mcp.ts
55
+ import { McpContext, McpNamespace } from '@node-in-layers/mcp-server'
56
+ import { Config } from '@node-in-layers/core'
57
+ import { YourFeaturesLayer } from './features.js'
58
+
59
+ const create = (context: McpContext<Config, YourFeaturesLayer>) => {
60
+ // Adds your tool.
61
+ context.mcp[McpNamespace].addTool({
62
+ name: 'my-hello-world-tool',
63
+ description: 'My Tool',
64
+ execute: async (input: any) => {
65
+ return 'Hello, world!'
66
+ },
67
+ })
68
+
69
+ // Create a tool from your feature
70
+ context.mcp[McpNamespace].addTool({
71
+ name: 'my-hello-world-tool',
72
+ description: 'My Tool',
73
+ inputSchema: {
74
+ type: 'object',
75
+ properties: {
76
+ name: {
77
+ type: 'string',
78
+ },
79
+ },
80
+ required: ['name'],
81
+ },
82
+ execute: (input: any) => {
83
+ // You get an object, pass it back to your feature. Handles async for you.
84
+ return context.features.yourDomain.yourFeature(input)
85
+ },
86
+ })
87
+
88
+ return {}
89
+ }
90
+
91
+ export { create }
92
+ ```
93
+
94
+ ### Adding Models
95
+
96
+ You can wrap your models with CRUDS functions and add them to the MCP server with the mcp layer.
97
+ NOTE: In order for this to work your layer must have both a services and a features layer. (In addition to your models.) Node in layers will automatically create a cruds property for you with your models, and you can add them.
98
+
99
+ Here is an example of doing it one at a time. (Not generally recommended, but doable).
100
+
101
+ ```typescript
102
+ // /src/yourDomain/mcp.ts
103
+ import { McpContext, McpNamespace } from '@node-in-layers/mcp-server'
104
+ import { Config } from '@node-in-layers/core'
105
+ import { YourFeaturesLayer } from './features.js'
106
+
107
+ const create = (context: McpContext<Config, YourFeaturesLayer>) => {
108
+ // Adds your models cruds through features.
109
+ context.mcp[McpNamespace].addModelCruds(
110
+ context.features.yourFeature.cruds.Cars
111
+ )
112
+
113
+ return {}
114
+ }
115
+ ```
116
+
117
+ Here is a way that you can really cook with gas. (Highly recommended)
118
+
119
+ ```typescript
120
+ // /src/yourDomain/mcp.ts
121
+ import { McpContext, McpNamespace, mcpModels } from '@node-in-layers/mcp-server'
122
+ import { Config } from '@node-in-layers/core'
123
+ import { YourFeaturesLayer } from './features.js'
124
+
125
+ const create = (context: McpContext<Config, YourFeaturesLayer>) => {
126
+ // This automatically adds ALL of your models from features.
127
+ mcpModels('yourDomain')(context)
128
+
129
+ return {}
130
+ }
131
+ ```
132
+
133
+ Another way to organize adding models is from a centralized mcp domain. Put this as your very last domain after all your other domains have been loaded.
134
+
135
+ ```typescript
136
+ // /src/mcp/mcp.ts
137
+ import { McpContext, McpNamespace, mcpModels } from '@node-in-layers/mcp-server'
138
+ import { Config } from '@node-in-layers/core'
139
+
140
+ const create = (context: McpContext<Config>) => {
141
+ // Add all your models for your whole system in one go.
142
+ mcpModels('yourDomain')(context)
143
+ mcpModels('yourDomain2')(context)
144
+ mcpModels('yourDomain3')(context)
145
+ mcpModels('yourDomain4')(context)
146
+
147
+ return {}
148
+ }
149
+ ```
package/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * as mcp from './mcp.js';
2
+ declare const name = "@node-in-layers/mcp-server";
3
+ export { name };
package/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export * as mcp from './mcp.js';
2
+ const name = '@node-in-layers/mcp-server';
3
+ export { name };
4
+ //# sourceMappingURL=index.js.map
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAE/B,MAAM,IAAI,GAAG,4BAA4B,CAAA;AACzC,OAAO,EAAE,IAAI,EAAE,CAAA"}
package/mcp.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ import { Config, FeaturesContext } from '@node-in-layers/core';
2
+ import { ToolNameGenerator } from 'functional-models-orm-mcp';
3
+ import { McpServerMcp, McpServerConfig, McpContext } from './types.js';
4
+ declare const create: (context: McpContext<McpServerConfig & Config>) => McpServerMcp;
5
+ /**
6
+ * Automatically adds all the models in the given domain to the MCP server.
7
+ * @param namespace The namespace of the domain to add the models from.
8
+ * @param opts Options for the tool name generator.
9
+ * @returns A function that can be used to add the models to the MCP server.
10
+ */
11
+ declare const mcpModels: (namespace: string, opts: {
12
+ nameGenerator: ToolNameGenerator;
13
+ }) => (context: FeaturesContext & McpContext) => {};
14
+ export { create, mcpModels };
package/mcp.js ADDED
@@ -0,0 +1,134 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import get from 'lodash/get.js';
11
+ import { createSimpleServer } from '@l4t/mcp-ai/simple-server/index.js';
12
+ import { generateMcpToolForModelOperation, } from 'functional-models-orm-mcp';
13
+ import { v4 as uuidv4 } from 'uuid';
14
+ import { McpNamespace, } from './types.js';
15
+ const DEFAULT_RESPONSE_REQUEST_LOG_LEVEL = 'info';
16
+ const create = (context) => {
17
+ const tools = [];
18
+ const models = [];
19
+ const addTool = (tool) => {
20
+ // eslint-disable-next-line functional/immutable-data
21
+ tools.push(tool);
22
+ };
23
+ const addModelCruds = (cruds, opts) => {
24
+ // eslint-disable-next-line functional/immutable-data
25
+ models.push(..._createToolsForModelCruds(cruds, opts));
26
+ };
27
+ const _createToolsForModelCruds = (cruds, opts) => {
28
+ const model = cruds.getModel();
29
+ const tools = [
30
+ Object.assign(Object.assign({}, generateMcpToolForModelOperation(model, 'create', opts)), { execute: (input) => __awaiter(void 0, void 0, void 0, function* () {
31
+ return cruds.create(input);
32
+ }) }),
33
+ Object.assign(Object.assign({}, generateMcpToolForModelOperation(model, 'retrieve', opts)), { execute: ({ id }) => __awaiter(void 0, void 0, void 0, function* () {
34
+ return cruds.retrieve(id);
35
+ }) }),
36
+ Object.assign(Object.assign({}, generateMcpToolForModelOperation(model, 'update', opts)), { execute: (input) => __awaiter(void 0, void 0, void 0, function* () {
37
+ return cruds.update(model.getPrimaryKey(input), input);
38
+ }) }),
39
+ Object.assign(Object.assign({}, generateMcpToolForModelOperation(model, 'delete', opts)), { execute: ({ id }) => __awaiter(void 0, void 0, void 0, function* () {
40
+ yield cruds.delete(id);
41
+ }) }),
42
+ Object.assign(Object.assign({}, generateMcpToolForModelOperation(model, 'search', opts)), { execute: (input) => __awaiter(void 0, void 0, void 0, function* () {
43
+ return cruds.search(input);
44
+ }) }),
45
+ Object.assign(Object.assign({}, generateMcpToolForModelOperation(model, 'bulkInsert', opts)), { execute: (input) => __awaiter(void 0, void 0, void 0, function* () {
46
+ yield cruds.bulkInsert(input);
47
+ }) }),
48
+ Object.assign(Object.assign({}, generateMcpToolForModelOperation(model, 'bulkDelete', opts)), { execute: (input) => __awaiter(void 0, void 0, void 0, function* () {
49
+ yield cruds.bulkDelete(input);
50
+ }) }),
51
+ ];
52
+ return tools;
53
+ };
54
+ const _wrapToolsWithLogger = (tool) => {
55
+ const execute = (input) => __awaiter(void 0, void 0, void 0, function* () {
56
+ var _a;
57
+ const requestId = uuidv4();
58
+ const logger = context.log
59
+ .getIdLogger('logRequest', 'requestId', requestId)
60
+ .applyData({
61
+ requestId: requestId,
62
+ });
63
+ const level = ((_a = context.config[McpNamespace].logging) === null || _a === void 0 ? void 0 : _a.requestLogLevel) ||
64
+ DEFAULT_RESPONSE_REQUEST_LOG_LEVEL;
65
+ logger[level]('Request received', {
66
+ method: 'POST',
67
+ url: '/',
68
+ body: input,
69
+ });
70
+ const result = yield tool.execute(input, {
71
+ logging: {
72
+ ids: logger.getIds(),
73
+ },
74
+ });
75
+ logger[level]('Request Response', {
76
+ response: result,
77
+ });
78
+ return result;
79
+ });
80
+ return Object.assign(Object.assign({}, tool), { execute });
81
+ };
82
+ const _getServer = (expressOptions) => {
83
+ const allTools = [...tools, ...models].map(_wrapToolsWithLogger);
84
+ const server = createSimpleServer(Object.assign({ name: context.config[McpNamespace].name || '@node-in-layers/mcp-server', version: context.config[McpNamespace].version || '1.0.0', tools: allTools }, context.config[McpNamespace].server),
85
+ // @ts-ignore
86
+ expressOptions);
87
+ return server;
88
+ };
89
+ const start = (expressOptions) => __awaiter(void 0, void 0, void 0, function* () {
90
+ const server = _getServer(expressOptions);
91
+ yield server.start();
92
+ });
93
+ const getApp = (expressOptions) => {
94
+ const server = _getServer(expressOptions);
95
+ // @ts-ignore
96
+ if (!(server === null || server === void 0 ? void 0 : server.getApp)) {
97
+ throw new Error(`Server not http or sse`);
98
+ }
99
+ // @ts-ignore
100
+ return server.getApp();
101
+ };
102
+ return {
103
+ start,
104
+ getApp,
105
+ addTool,
106
+ addModelCruds,
107
+ };
108
+ };
109
+ /**
110
+ * Automatically adds all the models in the given domain to the MCP server.
111
+ * @param namespace The namespace of the domain to add the models from.
112
+ * @param opts Options for the tool name generator.
113
+ * @returns A function that can be used to add the models to the MCP server.
114
+ */
115
+ const mcpModels = (namespace, opts) => (context) => {
116
+ const expressFunctions = context.mcp[McpNamespace];
117
+ const namedFeatures = get(context, `features.${namespace}`);
118
+ if (!namedFeatures) {
119
+ throw new Error(`features.${namespace} does not exist on context needed for express.`);
120
+ }
121
+ // Look for CRUDS functions.
122
+ Object.entries(namedFeatures).forEach(([key, value]) => {
123
+ if (typeof value === 'object') {
124
+ if (key === 'cruds') {
125
+ Object.entries(value).forEach(([, modelCrudFuncs]) => {
126
+ expressFunctions.addModelCruds(modelCrudFuncs, opts);
127
+ });
128
+ }
129
+ }
130
+ }, {});
131
+ return {};
132
+ };
133
+ export { create, mcpModels };
134
+ //# sourceMappingURL=mcp.js.map
package/mcp.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp.js","sourceRoot":"","sources":["../src/mcp.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,GAAG,MAAM,eAAe,CAAA;AAM/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAA;AAGvE,OAAO,EACL,gCAAgC,GAEjC,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MA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AE,SAAS,EAAE,CAAA"}
package/package.json ADDED
@@ -0,0 +1,71 @@
1
+ {
2
+ "name": "@node-in-layers/mcp-server",
3
+ "type": "module",
4
+ "version": "1.0.0",
5
+ "description": "An MCP Server Node In Layers Package, generated by the Node In Layers Toolkit.",
6
+ "main": "index.js",
7
+ "scripts": {
8
+ "build": "rm -Rf ./dist && tsc -p ./tsconfig.json && cp package.json ./dist && cp README.md ./dist",
9
+ "build:watch": "nodemon -e '*' --watch ./src --exec \"npm run build || exit 1\"",
10
+ "commit": "cz",
11
+ "dist": "npm run build && cd dist && npm publish",
12
+ "eslint": "eslint .",
13
+ "feature-tests": "./node_modules/.bin/cucumber-js -p default",
14
+ "prettier": "prettier --write .",
15
+ "test": "export TS_NODE_TRANSPILE_ONLY=true && export TS_NODE_PROJECT='./tsconfig.test.json' && mocha -r ts-node/register 'test/**/*.test.ts'",
16
+ "test:coverage": "nyc --all --reporter cobertura --reporter text --reporter lcov --reporter html npm run test"
17
+ },
18
+ "config": {
19
+ "commitizen": {
20
+ "path": "./node_modules/cz-conventional-changelog"
21
+ }
22
+ },
23
+ "author": "",
24
+ "license": "ISC",
25
+ "devDependencies": {
26
+ "@cucumber/cucumber": "11.0.1",
27
+ "@eslint/compat": "^1.2.0",
28
+ "@eslint/eslintrc": "^3.1.0",
29
+ "@eslint/js": "^9.12.0",
30
+ "@istanbuljs/nyc-config-typescript": "^1.0.2",
31
+ "@types/chai-as-promised": "^8.0.1",
32
+ "@types/json-stringify-safe": "^5.0.3",
33
+ "@types/lodash": "^4.17.13",
34
+ "@types/mocha": "^9.1.1",
35
+ "@types/node": "^22.9.0",
36
+ "@types/proxyquire": "^1.3.31",
37
+ "@types/sinon": "^17.0.3",
38
+ "@typescript-eslint/eslint-plugin": "8.13.0",
39
+ "@typescript-eslint/parser": "8.13.0",
40
+ "argparse": "^2.0.1",
41
+ "chai": "^4.2.0",
42
+ "chai-as-promised": "^7.1.1",
43
+ "cz-conventional-changelog": "^3.3.0",
44
+ "eslint": "9.14.0",
45
+ "eslint-config-prettier": "^9.1.0",
46
+ "eslint-import-resolver-typescript": "^3.6.3",
47
+ "eslint-plugin-functional": "~7.1.0",
48
+ "eslint-plugin-import": "^2.31.0",
49
+ "globals": "^15.12.0",
50
+ "handlebars": "^4.7.8",
51
+ "js-yaml": "^4.1.0",
52
+ "mocha": "^11.0.1",
53
+ "nodemon": "^3.1.7",
54
+ "nyc": "^17.1.0",
55
+ "prettier": "^3.3.3",
56
+ "proxyquire": "^2.1.3",
57
+ "sinon": "^19.0.2",
58
+ "sinon-chai": "^3.5.0",
59
+ "source-map-support": "^0.5.21",
60
+ "ts-node": "^10.4.0",
61
+ "typescript": "5.3.3"
62
+ },
63
+ "dependencies": {
64
+ "@l4t/mcp-ai": "^1.3.0",
65
+ "@node-in-layers/core": "^1.5.5",
66
+ "express": "^5.1.0",
67
+ "functional-models": "^3.0.16",
68
+ "functional-models-orm-mcp": "^3.0.1",
69
+ "uuid": "^11.1.0"
70
+ }
71
+ }
package/types.d.ts ADDED
@@ -0,0 +1,31 @@
1
+ import { ServerTool, SimpleServerConfig } from '@l4t/mcp-ai/simple-server/types.js';
2
+ import { Config, CommonContext, LogLevelNames, LayerContext, ModelCrudsFunctions } from '@node-in-layers/core';
3
+ import { Express } from 'express';
4
+ import { ToolNameGenerator } from 'functional-models-orm-mcp';
5
+ export type McpServerConfig = Readonly<{
6
+ [McpNamespace]: {
7
+ name?: string;
8
+ version?: string;
9
+ server: SimpleServerConfig;
10
+ logging?: {
11
+ requestLogLevel: LogLevelNames;
12
+ responseLogLevel: LogLevelNames;
13
+ };
14
+ };
15
+ }>;
16
+ export declare const McpNamespace = "@node-in-layers/mcp-server";
17
+ export type McpServerMcp = Readonly<{
18
+ start: () => Promise<void>;
19
+ addTool: (tool: ServerTool) => void;
20
+ getApp: () => Express;
21
+ addModelCruds: (modelCruds: ModelCrudsFunctions<any>, opts: {
22
+ nameGenerator: ToolNameGenerator;
23
+ }) => void;
24
+ }>;
25
+ export type McpServerMcpLayer = Readonly<{
26
+ [McpNamespace]: McpServerMcp;
27
+ }>;
28
+ export type McpContext<TConfig extends Config = Config, TFeatures extends object = object, TMcpLayer extends object = object> = LayerContext<TConfig, {
29
+ features: TFeatures;
30
+ mcp: McpServerMcpLayer & TMcpLayer;
31
+ }> & CommonContext<TConfig>;
package/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export const McpNamespace = '@node-in-layers/mcp-server';
2
+ //# sourceMappingURL=types.js.map
package/types.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AA0BA,MAAM,CAAC,MAAM,YAAY,GAAG,4BAA4B,CAAA"}