Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules/
knowledge-mcp/src/knowledge/entries.json
*.json
dist/
*.html
Expand Down
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -650,3 +650,24 @@ In this situation, the latinName for species is not passed in, but calculated fr
A date property that automatically updates whenever the model instance is saved.

[Documentation](https://monolithst.github.io/functional-models/functions/index.orm.properties.LastModifiedDateProperty.html)

# MCP Development Server

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.

## Quick Start

You can setup the server by setting up Cursor (or similar) with this configuration.

```json
{
"mcpServers": {
"node-in-layers-core": {
"command": "npx",
"args": ["-y", "@functional-models/knowledge-mcp"]
}
}
}
```

You can learn more about this here [Knowledge MCP](./knowledge-mcp/README.md)
1 change: 1 addition & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default [
ignores: [
'buildDocs',
'eslint.config.mjs',
'knowledge-mcp/',
'dist/',
'node_modules/',
'test/',
Expand Down
33 changes: 33 additions & 0 deletions knowledge-mcp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Development Mcp Tool for Functional models

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.

## How To Use

You can use this as a CLI MCP tool with any normal AI service. Here is an example used with Cursor.

```json
{
"mcpServers": {
"node-in-layers-core": {
"command": "npx",
"args": ["-y", "@functional-models/knowledge-mcp"]
}
}
}
```

### Selecting a specific version.

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.

```json
{
"mcpServers": {
"node-in-layers-core": {
"command": "npx",
"args": ["-y", "@functional-models/knowledge-mcp@3.6.2"]
}
}
}
```
29 changes: 29 additions & 0 deletions knowledge-mcp/bin/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash
set -e

# Build parent core package so we can embed it
npm --prefix .. run build

rm -Rf ./dist

# Bundle built core into local node_modules for runtime self-containment
rm -Rf ./node_modules/functional-models
mkdir -p ./node_modules/functional-models
cp -R ../dist/* ./node_modules/functional-models/

npm run tsc -- -p ./tsconfig.json
node - <<'NODE'
const fs = require('fs');
const corePkg = JSON.parse(fs.readFileSync('../package.json','utf8'));
const mcpPkg = JSON.parse(fs.readFileSync('./package.json','utf8'));
mcpPkg.version = corePkg.version;
mcpPkg.dependencies = mcpPkg.dependencies || {};
mcpPkg.dependencies['functional-models'] = corePkg.version;
fs.mkdirSync('./dist', { recursive: true });
fs.writeFileSync('./dist/package.json', JSON.stringify(mcpPkg, null, 2));
NODE
cp README.md ./dist
cp -R ./bin/ ./dist/
rm ./dist/bin/build.sh

sed -i -e 's/..\/dist\//..\//g' ./dist/bin/mcp_server.js
29 changes: 29 additions & 0 deletions knowledge-mcp/bin/mcp_server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env tsx

import esMain from 'es-main'
import { ArgumentParser } from 'argparse'
import * as core from '@node-in-layers/core'
import { default as config } from '../dist/config.js'

const _parseArguments = () => {
const parser = new ArgumentParser({
description: 'Starts the MCP server.',
})
return parser.parse_args()
}

const startServer = async () => {
const context = await core.loadSystem({
environment: 'prod',
config: await config(),
})
await context.mcp.mcp.start()
}

if (esMain(import.meta)) {
const args = _parseArguments()
startServer(args.environment).catch(error => {
console.error('Failed to start the server:', error)
process.exit(1)
})
}
Loading