Skip to content

Commit feb4e7c

Browse files
authored
Merge pull request #43 from monolithst/getname
Getname
2 parents 152f7cb + eff8793 commit feb4e7c

32 files changed

Lines changed: 11522 additions & 1070 deletions

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
node_modules/
2+
knowledge-mcp/src/knowledge/entries.json
23
*.json
34
dist/
45
*.html

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,3 +650,24 @@ In this situation, the latinName for species is not passed in, but calculated fr
650650
A date property that automatically updates whenever the model instance is saved.
651651

652652
[Documentation](https://monolithst.github.io/functional-models/functions/index.orm.properties.LastModifiedDateProperty.html)
653+
654+
# MCP Development Server
655+
656+
Functional Models has an MCP server for AI based development. It provides knowledge entries for the AI to have specific examples of how to work with and manipulate models in a system. This GREATLY increases the accuracy and understanding of AI working with these systems, making it really easy to add new features, refactor, and make the best use of features.
657+
658+
## Quick Start
659+
660+
You can setup the server by setting up Cursor (or similar) with this configuration.
661+
662+
```json
663+
{
664+
"mcpServers": {
665+
"node-in-layers-core": {
666+
"command": "npx",
667+
"args": ["-y", "@functional-models/knowledge-mcp"]
668+
}
669+
}
670+
}
671+
```
672+
673+
You can learn more about this here [Knowledge MCP](./knowledge-mcp/README.md)

eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export default [
2323
ignores: [
2424
'buildDocs',
2525
'eslint.config.mjs',
26+
'knowledge-mcp/',
2627
'dist/',
2728
'node_modules/',
2829
'test/',

knowledge-mcp/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Development Mcp Tool for Functional models
2+
3+
Whenever you build a system using functional models, you can use this MCP tool to teach the AI how to actually interact and work with your models.
4+
5+
## How To Use
6+
7+
You can use this as a CLI MCP tool with any normal AI service. Here is an example used with Cursor.
8+
9+
```json
10+
{
11+
"mcpServers": {
12+
"node-in-layers-core": {
13+
"command": "npx",
14+
"args": ["-y", "@functional-models/knowledge-mcp"]
15+
}
16+
}
17+
}
18+
```
19+
20+
### Selecting a specific version.
21+
22+
If you want the development knowledge to match the version of Node In Layers Core you are using, you can put it in the npx command.
23+
24+
```json
25+
{
26+
"mcpServers": {
27+
"node-in-layers-core": {
28+
"command": "npx",
29+
"args": ["-y", "@functional-models/knowledge-mcp@3.6.2"]
30+
}
31+
}
32+
}
33+
```

knowledge-mcp/bin/build.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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/functional-models
11+
mkdir -p ./node_modules/functional-models
12+
cp -R ../dist/* ./node_modules/functional-models/
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['functional-models'] = 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+
rm ./dist/bin/build.sh
28+
29+
sed -i -e 's/..\/dist\//..\//g' ./dist/bin/mcp_server.js

knowledge-mcp/bin/mcp_server.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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 { default as config } from '../dist/config.js'
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: await config(),
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 commit comments

Comments
 (0)