-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModuleConfig.bx
More file actions
177 lines (167 loc) · 6.28 KB
/
ModuleConfig.bx
File metadata and controls
177 lines (167 loc) · 6.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
/**
* Copyright Since 2005 ColdBox Framework by Luis Majano and Ortus Solutions, Corp
* www.ortussolutions.com
* ---
*/
class {
// Module Properties
this.title = "cbMCP"
this.author = "Ortus Solutions"
this.webURL = "https://www.ortussolutions.com"
this.description = "A collection of AI powered tools for ColdBox."
this.version = "@build.version@+@build.number@"
// Model Namespace
this.modelNamespace = "cbMCP"
// Class Mapping
this.classMapping = "cbMCP"
// Dependencies
this.dependencies = []
// URI Endpoint Prefix
this.entryPoint = "cbmcp"
/**
* Configure Module
*/
function configure(){
settings = {
}
}
/**
* Fired when the module is registered and activated.
*/
function onLoad(){
// Register our MCP Server here
mcpServer(
name: "cbMCP",
description: "An MCP Server for ColdBox AI Tools",
version: "@build.version@+@build.number@",
cors: "*",
statsEnabled: true,
force: true
)
// Register tools
.scan( "cbMCP.models.tools" )
// -------------------------------------------------------------------------
// Resources — ambient read-only context surfaced to the AI client
// -------------------------------------------------------------------------
.registerResource(
uri : "coldbox://app/settings",
name : "ColdBox Application Settings",
description : "All active ColdBox application configuration settings",
mimeType : "application/json",
handler : () => {
var settings = application.cbController.getConfigSettings()
// Keep only serialisable scalar / array / struct values
var safe = {}
for ( var key in settings ) {
var val = settings[ key ]
if ( isSimpleValue( val ) || isArray( val ) || isStruct( val ) ) {
safe[ key ] = val
}
}
return ( safe )
}
)
.registerResource(
uri : "coldbox://app/modules",
name : "Loaded ColdBox Modules",
description : "All currently activated HMVC modules with their key metadata",
mimeType : "application/json",
handler : () => {
var modules = application.cbController.getSetting( "modules" )
var result = modules
.keyArray()
.sort( "text", "asc" )
.map( name => {
var m = modules[ name ]
return {
"name" : name,
"version" : m.version ?: "",
"description" : m.description ?: "",
"entryPoint" : m.entryPoint ?: "",
"author" : m.author ?: "",
"activated" : m.activated ?: false
}
} )
return ( result )
}
)
.registerResource(
uri : "coldbox://app/routes",
name : "ColdBox Route Definitions",
description : "All registered URL routes with their patterns and handler targets",
mimeType : "application/json",
handler : () => {
var routes = application.cbController.getRoutingService().getRouter().getRoutes()
var result = routes.map( r => {
return {
"pattern" : r.pattern ?: "",
"handler" : r.handler ?: "",
"action" : r.action ?: "",
"name" : r.name ?: "",
"methods" : r.methods ?: [],
"module" : r.module ?: "",
"namespace" : r.namespace ?: ""
}
} )
return ( result )
}
)
.registerResource(
uri : "coldbox://app/handlers",
name : "Registered ColdBox Handlers",
description : "All registered event handlers (controllers) in the application",
mimeType : "application/json",
handler : () => {
var handlers = listToArray( application.cbController.getSetting( "registeredHandlers" ) )
handlers.sort( "text", "asc" )
return ( handlers )
}
)
// -------------------------------------------------------------------------
// Prompts — pre-packaged AI workflows surfaced in the client prompt library
// -------------------------------------------------------------------------
.registerPrompt(
name : "coldbox_app_overview",
description : "Generates a comprehensive overview of this ColdBox application",
handler : () => {
var ctrl = application.cbController
var appName = ctrl.getSetting( "appName" )
var modules = ctrl.getSetting( "modules" ).keyArray().sort( "text", "asc" )
return "Provide a comprehensive overview of this ColdBox application. Here is what I know so far:
App Name : #appName#
Modules : #modules.toList()#
Use the available MCP tools (get_coldbox_settings, get_application_structure, get_router_settings, get_interceptors, etc.) to gather additional details, then summarise the architecture, key modules, routing strategy, and any notable configuration."
}
)
.registerPrompt(
name : "debug_handler",
description : "Diagnoses issues with a specific ColdBox event handler",
args : [
{ name: "handlerName", description: "The handler to investigate (e.g. 'Main' or 'api:Users')", required: true }
],
handler : ( handlerName = "" ) => {
return "Diagnose the ColdBox handler '#handlerName#'. Use the get_handler_metadata and get_registered_handlers MCP tools to gather details, then identify any potential issues with routing, dependency injection, or event execution lifecycle."
}
)
.registerPrompt(
name : "cache_health_report",
description : "Produces a CacheBox health report for all cache providers",
handler : () => {
return "Generate a CacheBox health report for this ColdBox application. Use the get_caches and get_cache_stats MCP tools to collect data on each cache provider, then summarise hit rates, eviction counts, object counts, and identify any providers showing signs of memory pressure or degraded performance."
}
)
.registerPrompt(
name : "interceptor_audit",
description : "Audits all registered ColdBox interceptors and their interception points",
handler : () => {
return "Audit the ColdBox interceptors for this application. Use the get_interceptors MCP tool to list all registered interceptors and their interception points. Identify interceptors listening on the same points that might conflict, flag any with unusual names or patterns, and suggest ordering improvements where applicable."
}
)
}
/**
* Fired when the module is unregistered and unloaded
*/
function onUnload(){
//aiService().removeServer( "cbMCP" )
}
}