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
13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "functional-models-orm-mcp",
"version": "3.2.1",
"version": "3.5.0",
"description": "A functional-models-orm datastore provider that uses the @modelcontextprotocol/sdk. Great for using models on a frontend.",
"main": "index.js",
"types": "index.d.ts",
Expand Down Expand Up @@ -41,7 +41,7 @@
},
"homepage": "https://github.com/monolithst/functional-models-orm-rest-client#readme",
"devDependencies": {
"@cucumber/cucumber": "11.0.1",
"@cucumber/cucumber": "^11.3.0",
"@eslint/compat": "^1.2.0",
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.12.0",
Expand All @@ -58,13 +58,14 @@
"c8": "^10.1.3",
"chai": "^5.1.2",
"chai-as-promised": "^8.0.1",
"cz-conventional-changelog": "^3.3.0",
"cz-conventional-changelog": "^3.0.1",
"eslint": "9.14.0",
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-typescript": "^3.6.3",
"eslint-plugin-functional": "~7.1.0",
"eslint-plugin-import": "^2.31.0",
"esprima": "^4.0.1",
"functional-models-orm-memory": "^3.0.0",
"globals": "^15.12.0",
"handlebars": "^4.7.8",
"js-yaml": "^4.1.0",
Expand All @@ -84,8 +85,10 @@
"@l4t/mcp-ai": "^1.5.0",
"@modelcontextprotocol/sdk": "^1.11.4",
"axios": "^1.9.0",
"functional-models": "^3.0.16",
"functional-models": "^3.5.1",
"functional-models-openapi": "^3.0.2",
"lodash": "^4.17.21",
"uuid": "^11.1.0"
"uuid": "^11.1.0",
"zod": "^4.1.11"
}
}
32 changes: 25 additions & 7 deletions src/datastoreProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { SSEClientTransport } from '@modelcontextprotocol/sdk/client/sse.js'
import { v4 as uuidv4 } from 'uuid'
import axios from 'axios'
import { createOAuth2Manager } from './oauth2'
import { McpToolMeta, DatastoreProviderConfig } from './types'
import { McpToolMeta, DatastoreProviderConfig, ModelOperation } from './types'
import { generateMcpToolForModelOperation } from './libs'

const createTransport = (
Expand Down Expand Up @@ -144,7 +144,10 @@ const datastoreProvider = (
instance: ModelInstance<T>
) => {
const model = instance.getModel()
const tool = generateMcpToolForModelOperation(model as any, 'save')
const tool = generateMcpToolForModelOperation(
model as any,
ModelOperation.save
)
const input = await instance.toObj()
return executeTool(tool, input)
}
Expand All @@ -154,15 +157,21 @@ const datastoreProvider = (
model: any,
instances: readonly ModelInstance<T>[]
) => {
const tool = generateMcpToolForModelOperation(model as any, 'bulkInsert')
const tool = generateMcpToolForModelOperation(
model as any,
ModelOperation.bulkInsert
)
const input = { items: await Promise.all(instances.map(i => i.toObj())) }
await executeTool(tool, input)
return
}

// RETRIEVE
const retrieve = async (model: any, id: PrimaryKeyType) => {
const tool = generateMcpToolForModelOperation(model as any, 'retrieve')
const tool = generateMcpToolForModelOperation(
model as any,
ModelOperation.retrieve
)
return executeTool(tool, { id })
}

Expand All @@ -171,7 +180,10 @@ const datastoreProvider = (
model: ModelType<T>,
id: PrimaryKeyType
) => {
const tool = generateMcpToolForModelOperation(model as any, 'delete')
const tool = generateMcpToolForModelOperation(
model as any,
ModelOperation.delete
)
await executeTool(tool, { id })
return
}
Expand All @@ -181,7 +193,10 @@ const datastoreProvider = (
model: ModelType<T>,
ormQuery: any
) => {
const tool = generateMcpToolForModelOperation(model as any, 'search')
const tool = generateMcpToolForModelOperation(
model as any,
ModelOperation.search
)
return executeTool(tool, ormQuery)
}

Expand All @@ -190,7 +205,10 @@ const datastoreProvider = (
model: ModelType<T>,
ids: readonly PrimaryKeyType[]
) => {
const tool = generateMcpToolForModelOperation(model as any, 'bulkDelete')
const tool = generateMcpToolForModelOperation(
model as any,
ModelOperation.bulkDelete
)
await executeTool(tool, { ids })
return
}
Expand Down
Loading
Loading