@progress/kendo-jquery-mcp
Version:
Model Context Protocol for KendoJQuery
43 lines (37 loc) • 8.68 kB
JavaScript
var A=Object.defineProperty;var _=(e,o,t)=>o in e?A(e,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[o]=t;var g=(e,o,t)=>_(e,typeof o!="symbol"?o+"":o,t);import{McpServer as F}from"@modelcontextprotocol/sdk/server/mcp.js";import{StdioServerTransport as O}from"@modelcontextprotocol/sdk/server/stdio.js";import{z as I}from"zod";var a="Kendo UI for jQuery",v="jquery",k=["AIPrompt","ActionSheet","AppBar","ArcGauge","AutoComplete","Avatar","Badge","Barcode","BottomNavigation","Breadcrumb","BulletChart","Button","ButtonGroup","Calendar","Captcha","Card","Chart","ChartWizard","Chat","CheckBoxGroup","Checkbox","Chip","ChipList","CircularGauge","CircularProgressBar","Collapsible","ColorGradient","ColorPalette","ColorPicker","ComboBox","ContextMenu","DataSource","DatePicker","DateInput","DateRangePicker","DateTimePicker","Diagram","Dialog","DockManager","DragandDrop","Drawer","DrawingAPI","DropDownButton","DropDownList","DropDownTree","Editor","Effects","ExpansionPanel","FileManager","Filter","FlatColorPicker","FloatingActionButton","Form","Gantt","Globalization","Grid","Heatmap","HierarchicalDataSource","ImageEditor","InlineAIPrompt","Licensing","LinearGauge","ListBox","ListView","Loader","MVVM","Map","MaskedTextBox","MediaPlayer","Menu","MultiColumnComboBox","MultiSelect","MultiViewCalendar","Notification","NumericTextBox","OTP Input","OrgChart","PDFViewer","Pager","PanelBar","PivotGrid","PivotGridV2","Popover","Popup","ProgressBar","PropertyGrid","QRCode","RadialGauge","RadioButton","RadioGroup","RangeSlider","Rating","ResponsivePanel","RippleContainer","SPA","Sankey","Scheduler","ScrollView","Signature","SkeletonContainer","Slider","Sortable","Sparkline","SpeechToTextButton","SplitButton","Splitter","Spreadsheet","Stepper","StockChart","Switch","TabStrip","TaskBoard","Templates","TextArea","TextBox","TileLayout","TimeDurationPicker","TimePicker","Timeline","ToggleButton","Toolbar","Tooltip","Touch","TreeList","TreeMap","TreeView","Upload","VSCodeExtension","Validator","Window","Wizard"];import{dirname as R,join as b}from"path";import{fileURLToPath as B}from"url";import{readFileSync as N}from"node:fs";import s from"node:fs";import m from"node:path";import U from"@grpc/proto-loader";import h from"@grpc/grpc-js";var E=["TELERIK_LICENSE","KENDO_UI_LICENSE"],w="TELERIK_LICENSE_PATH",l=(e=>(e[e.UNAUTHENTICATED=16]="UNAUTHENTICATED",e[e.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",e[e.PERMISSION_DENIED=7]="PERMISSION_DENIED",e))(l||{}),S=!1,i=process.env.DEBUG_LOG_FILE,C=!!(i&&typeof i=="string");if(C){let e=m.resolve(i),o=m.dirname(e);if(o!=="."&&o!==process.cwd()&&!s.existsSync(o))try{s.mkdirSync(o,{recursive:!0})}catch(t){console.error("Error creating log directory:",t)}if(!s.existsSync(e))try{s.writeFileSync(e,"")}catch(t){console.error("Error creating log file:",t)}}else S=!1;S=C&&!!i&&s.existsSync(m.resolve(i));function n(...e){if(S&&i){let o=`${new Date().toISOString()}: ${e.join(" ")}
`,t=m.resolve(i);s.appendFile(t,o,r=>{r&&console.error("Error writing to log file:",r)})}}var c=process.env[w],y=process.env[E[0]]||process.env[E[1]],f=class extends Error{constructor(e){super(e),this.name="LicenseError"}};function L(){if(!c&&!y)throw new f(`No license found. Please set one of the following environment variables: ${E.join(", ")} or ${w}`);let e;if(c)try{e=N(c,"utf8"),n("License key read from file: ",c)}catch{throw new f(`Error reading license file: ${c}. Please verify the file exists and is readable.`)}return y&&(e=y,n("License key read from environment variable.")),e}var x=class{constructor(e,o){g(this,"client");g(this,"isDev");this.contextApiUrl=e,this.protoPath=o;let t=U.loadSync(this.protoPath,{keepCase:!0,longs:String,enums:String,defaults:!0,oneofs:!0});this.isDev=this.contextApiUrl?.includes("localhost")||this.contextApiUrl?.includes("127.0.0.1"),n("Using ContextApi URl:",this.contextApiUrl);let r=h.loadPackageDefinition(t);this.client=new r.ContextQueryService(this.contextApiUrl||"contextapi.telerik.com:443",this.isDev?h.credentials.createInsecure():h.credentials.createSsl())}async query(e){let o=this.isDev?"fake_license":L(),t=new h.Metadata;if(o&&typeof o=="string"){o=o.replace(/^\uFEFF/,"");try{t.add("x-license-key",o)}catch(r){return n("Error adding license key to metadata:",r),Promise.reject(new Error(`Failed to use license key: ${r.message}`))}}return o&&typeof o=="string"&&t.add("x-license-key",o),new Promise((r,p)=>{this.client.query(e,t,(u,d)=>{u?p(u):r(d)})})}};var G=b(R(B(import.meta.url)),"../proto/service.proto"),M=new x("contextapi.telerik.com:443",G);async function T(e){return M.query(e)}import q from"fs";import P from"path";import{fileURLToPath as V}from"url";var J=V(import.meta.url),j=P.dirname(J),$=P.resolve(j,"../package.json"),H=JSON.parse(q.readFileSync($,"utf-8")),D=new F({name:"kendo-and-kendo-resources",version:H.version});D.tool("kendo_jquery_assistant",`Answers questions and retrieves documentation about ${a}.
Use this tool when the user asks about ${a} features, specific components (e.g., Grid, Chart, Editor), implementation details, or general usage.
Provide the user's detailed question as the 'query'. If the question pertains to a specific ${a} component,
specify its name in the 'component' parameter. This tool can be automatically triggered when the following phrases are detected in the user's input/prompt:
- 'kendo';
- '/kendo';
- '/kendojquery';
- '/ask_kendo';
- '/help_kendo';
- '@kendo';
- '@kendojquery';
- '@ask_kendo';
- '@help_kendo'.`,{query:I.string().describe("The query to search for."),component:I.enum(k).describe("The component to search for. If not specified, you can use General.")},async({query:e,component:o})=>{n("Calling tool: ",JSON.stringify({query:e,component:o}));try{let t=await T({query:e,component:o.toLocaleLowerCase(),lib_name:v,text_matches_count:3,code_matches_count:0,allowed_types:["documentation"]}),r=Q(),p=t.values.join(`
`),u=p.trim();n("Response from context API: ",JSON.stringify(t));let d=[{type:"text",text:p+(u?`
`+r:"")}];return n("Response from tool: ",JSON.stringify(d)),{content:d}}catch(t){throw n("Error calling context API: ",JSON.stringify(t)),t?.code===l.UNAUTHENTICATED?new Error("Error: You are not authenticated. Please verify the Telerik License Key provided is valid."):t?.code===l.RESOURCE_EXHAUSTED?new Error(`Error: You have exceeded the extension quota. Upgrade to subscription licensing in order to unlock full access. Message: ${t.message}.`):t?.code===l.PERMISSION_DENIED?new Error(`Error: You do not have permission to access this resource. Please verify that you have a valid ${a} license key.`):t instanceof f?(n("License error: ",t.message),t):new Error(`Error: An error occurred while calling the service. Please try again later.
Error Message: ${t.message}`)}});function Q(){return`
For CDN usage:
- If the user requests CDN links without specifying a version, provide the latest version URLs:
JavaScript: https://unpkg.com/@progress/kendo-ui@latest/umd/kendo.all.min.js
CSS: https://unpkg.com/@progress/kendo-theme-bootstrap@latest/dist/bootstrap-main.css
Font Icons: https://unpkg.com/@progress/kendo-font-icons/dist/index.css
- If the user specifies a particular version, use that version in the URLs (replace @latest with @version)
- If the user already has CDN links in their code, only suggest changes if they ask for updates or if there are issues
- If the user is using npm/local installation, do not suggest CDN links unless they specifically ask to switch
For all components:
- Always use let and const, never use var.
- Always use functional templates, never use string templates. Never use external <script> tags for templates. Never use the #= and #: syntax.
- Always use SVG icons instead of font icons when possible.
- If the user uses font icons, ensure they have called kendo.setDefaults("iconType", "font") before initializing any component, and have included the font icons CSS file.
- If the user uses SVG icons, ensure they use the JavaScript method kendo.ui.icon("icon-name") to render the icon.
- To update a component's options, use the setOptions method if available, or destroy and recreate the component. Never initialize a component twice on the same element.
- If the user uses api endpoints in their application, use them when working with remote data binding. If no api endpoints exist and the user has not asked you to use one, then use placeholders such as '/fake/api/endpoint'.
For the Grid component:
- Always specify a pageSize property in the pageable or datasource configuration to ensure pagination works correctly.
`}async function z(){let e=new O;n("Starting server..."),await D.connect(e)}z();