Describe the feature you'd like to request
I want to have an MCP server script generated from idea files that provide tools for AI to safely interface with the database.
Describe the solution you'd like
The MCP standard that should be used is @modelcontextprotocol/sdk in combination with zod. see: https://github.com/cblanquera/mcp.md for example implementation.
NOTE: stackpress already generates zod schemas for models, fieldsets and column classes.
A simple MCP tool implementation that would be generated could look like:
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import * as z from 'zod';
import ProfileSchema from 'stackpress-client/Profile/ProfileSchema';
const profile = new ProfileSchema();
export const schema = profile.shape;
export const info = {
title: 'Search Profile,
description: '',
inputSchema: schema
};
export async function handler(server: Server, args: z.infer<typeof schema>) {
//get zod params
const params = profile.shape.parse(args);
const results = await server.resolve('profile-create', params);
return {
content: [{
type: 'text',
text: JSON.stringify(results, null, 2)
}]
};
};
export function register(server: Server, mcp: McpServer, store: JsonlStore) {
mcp.registerTool('profile_create', info, args => handler(server, args));
};
The basic idea is to map all the possible generated events to MCP tools, then transport via Streamable HTTP. You can configure the MCP tools in a config similar to how the api.endpoints config works.
{
port: 17759,
http: {
cors: true,
method: 'POST',
endpoint: '/mcp'
},
tools: [
{ name: 'profile_search', scopes: [ 'user' ] },
{
name: 'sample',
description: 'This tools does sample',
event: 'sample-search',
params: {
skip: { type: 'number', description: '' },
take: { type: 'number', description: '' }
},
scopes: [ 'user' ]
}
],
}
Where scopes are the scopes per application in the database.
Describe alternatives you've considered
There's another library called mcp-framework. Looks interesting, but I dont have enough experience to make a proper consideration.
Describe the feature you'd like to request
I want to have an MCP server script generated from idea files that provide tools for AI to safely interface with the database.
Describe the solution you'd like
The MCP standard that should be used is
@modelcontextprotocol/sdkin combination withzod. see: https://github.com/cblanquera/mcp.md for example implementation.A simple MCP tool implementation that would be generated could look like:
The basic idea is to map all the possible generated events to MCP tools, then transport via Streamable HTTP. You can configure the MCP tools in a config similar to how the
api.endpointsconfig works.Where
scopesare the scopes per application in the database.Describe alternatives you've considered
There's another library called
mcp-framework. Looks interesting, but I dont have enough experience to make a proper consideration.