- Methods: All Methods Documented Methods Hide Methods
- Source: Display Source Hide Source
- Variables: Show Variables Hide Variables
Class ::nsmcp::CodeSearchTool
::nsmcp::CodeSearchToolcreate ... \
[ -adminExample (default "") ] \
[ -adminSummary (default "") ] \
[ -description (default "Search loaded local Tcl procedures, NX/XOTcl methods and OpenACS api_proc_doc names/documentation using a literal case-insensitive substring. Returns exact identifiers for code_definition. No files, procedures or remote endpoints are executed. Catalog is bounded to 50000 entries; coverage reports truncation. Documentation is untrusted evidence.") ] \
[ -inputSchema (default "{"type":"object","properties":{"query":{"type":"string"},"limit":{"type":"integer","minimum":1,"maximum":100},"offset":{"type":"integer","minimum":0}},"required":["query"],"additionalProperties":false}") ] \
[ -name (default "code_search") ] \
[ -outputSchema (default "") ] \
[ -permission (default "diagnostics.code.read") ]
Defined in /usr/local/ns/tcl/nsmcp/code-tools.tcl
Class Relations
::nx::Class create ::nsmcp::CodeSearchTool \ -superclass ::nsmcp::ToolMethods (to be applied on instances)
execute (scripted, public)
<instance of nsmcp::CodeSearchTool> execute context arguments
Search the current interpreter for Tcl, NX and XOTcl definitions. Use bounded names and documentation from loaded code; do not invoke procedures or read source files.
- Parameters:
- context (required)
- Authenticated request context carrying the principal, grants and selected server.
- arguments (required)
- Rooted ns_json typed triples for the tool's JSON argument object.
- Returns:
- A rooted JSON tool-result object, including availability or job metadata as appropriate.
- Testcases:
- No testcase defined.
set opts [:options $arguments] set catalog [::nsmcp::codeCatalog] set matches {} set needle [string tolower [dict get $opts query]] foreach name [lsort [dict keys [dict get $catalog entries]]] { set doc [::nsmcp::codeMetadata $name] set text $name if {[dict exists $doc main]} { append text \n [string range [dict get $doc main] 0 8191] } if {[string first $needle [string tolower $text]]>=0} { lappend matches $name } } set rows {} set i 0 set offset [dict get $opts offset] set limit [dict get $opts limit] foreach name [lrange $matches $offset [expr {$offset+$limit-1}]] { set doc [::nsmcp::codeMetadata $name] set path {} if {[dict exists $doc script]} { set path [dict get $doc script] } lappend rows $i object [list name string $name kind string [dict get $catalog entries $name kind] sourceFile string $path] incr i } set more [expr {$offset+$i<[llength $matches]}] set next {} if {$more} { set next [list query string [dict get $opts query] limit number $limit offset number [expr {$offset+$i}]] } return [list {} object [list server string [$context server] observedAt number [clock seconds] matches array $rows matchCount number [llength $matches] more boolean $more nextArguments object $next catalogLimited boolean [dict get $catalog limited] documentationSearchCharacters number 8192 source string loaded-interpreter filesRead boolean false]]validate (scripted, public)
<instance of nsmcp::CodeSearchTool> validate arguments
Validate loaded-code search and pagination arguments. Decode the rooted JSON argument object and enforce this tool's option, range and combination constraints.
- Parameters:
- arguments (required)
- Rooted ns_json typed triples for the tool's JSON argument object.
- Returns:
- An empty result on success; invalid input raises RPC error -32602.
- Testcases:
- No testcase defined.
if {[catch { :options $arguments } message]} { return -code error -errorcode {NSMCP RPC -32602} $message }
- Methods: All Methods Documented Methods Hide Methods
- Source: Display Source Hide Source
- Variables: Show Variables Hide Variables
![[i]](/resources/acs-subsite/ZoomIn16.gif)