@flowfuse/driver-localfs 2.31.4-c7f2d76-202606302009.0 → 2.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/localfs.js +110 -0
  3. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ #### 2.32.0: Release
2
+
3
+ - Sync changes to Insight support code across drivers (#330)
4
+ - feat: Add Insights support with get-features and call-tool/read-resource methods (#329)
5
+ - Bump actions/checkout from 6.0.3 to 7.0.0 (#328)
6
+ - ci: set dependabot pull request limit to 30 (#326)
7
+ - Bump hono from 4.12.23 to 4.12.25 (#325)
8
+ - Bump js-yaml from 4.1.1 to 4.2.0 (#324)
9
+ - Bump form-data from 4.0.5 to 4.0.6 (#323)
10
+ - Bump ws (#322)
11
+ - Bump actions/checkout from 6.0.2 to 6.0.3 (#317)
12
+
1
13
  #### 2.31.3: Release
2
14
 
3
15
 
package/localfs.js CHANGED
@@ -26,6 +26,18 @@ const fileHandles = {}
26
26
 
27
27
  let logger
28
28
 
29
+ /**
30
+ * @typedef {object} accessToken
31
+ * @property {string} [scheme] - auth scheme, e.g. 'Bearer'. Basic auth is currently rejected.
32
+ * @property {string} [token] - the token value
33
+ * @property {string|string[]} [scope] - token scope(s); only tokens including `ff-expert:mcp` are honoured
34
+ *
35
+ * @typedef {object} McpEndpointSpec - Specification for an MCP endpoint. Additional properties are allowed and will be passed back in the result (for correlation purposes).
36
+ * @property {string} endpoint - The path of the MCP server e.g. '/mcp'. Should not contain the host/port; those are determined to agent/launcher
37
+ * @property {object} [headers] - extra request headers to send with every MCP HTTP request
38
+ * @property {accessToken} [accessToken] - access token; merged into `Authorization` when scoped for MCP
39
+ */
40
+
29
41
  function getNextFreePort (ports, initialPort) {
30
42
  if (initialPort === undefined) {
31
43
  initialPort = initialPortNumber
@@ -630,6 +642,104 @@ module.exports = {
630
642
  }
631
643
  })
632
644
  },
645
+
646
+ // #region MCP Support
647
+
648
+ // MCP ROUTE: step 4 (hosted)
649
+ // Called By: forge app (forge/containers/wrapper.js)
650
+ // Calls To : launchers `command` endpoint in lib/admin.js
651
+
652
+ /**
653
+ * Get MCP features
654
+ * @param {Project} project - the project model instance
655
+ * @param {Array<string|McpEndpointSpec>} endpoints - list of MCP endpoints to query.
656
+ * Each entry may be a bare URL/path string, or an object `{ endpoint, headers?, accessToken? }`
657
+ * @returns {Object} MCP features
658
+ */
659
+ getMCPFeatures: async (project, endpoints) => {
660
+ const cachedProject = await this._projects.get(project.id)
661
+ if (cachedProject === undefined) {
662
+ throw new Error('Instance cannot get MCP features')
663
+ }
664
+ const port = await project.getSetting('port')
665
+ try {
666
+ const response = await got.post('http://localhost:' + (port + 1000) + '/flowforge/command', {
667
+ json: {
668
+ cmd: 'mcp:get-features',
669
+ data: {
670
+ endpoints
671
+ }
672
+ }
673
+ }).json()
674
+ return response
675
+ } catch (error) {
676
+ throw new Error(`Failed to get MCP features: ${error.message}`)
677
+ }
678
+ },
679
+
680
+ /**
681
+ * Call MCP endpoint
682
+ * @param {Project} project - the project model instance
683
+ * @param {string|McpEndpointSpec} endpoint - MCP endpoint to call.
684
+ * @param {string} name - Name of the MCP tool to call
685
+ * @param {Object} input - Arguments to pass to the MCP tool
686
+ * @returns {Object} MCP tool result
687
+ */
688
+ callMCPTool: async (project, endpoint, name, input) => {
689
+ const cachedProject = await this._projects.get(project.id)
690
+ if (cachedProject === undefined) {
691
+ throw new Error('Instance cannot call MCP tool')
692
+ }
693
+
694
+ const port = await project.getSetting('port')
695
+ try {
696
+ const response = await got.post('http://localhost:' + (port + 1000) + '/flowforge/command', {
697
+ json: {
698
+ cmd: 'mcp:call-tool',
699
+ data: {
700
+ endpoint,
701
+ name,
702
+ input
703
+ }
704
+ }
705
+ }).json()
706
+ return response
707
+ } catch (error) {
708
+ throw new Error(`Failed to call MCP tool: ${error.message}`)
709
+ }
710
+ },
711
+
712
+ /**
713
+ * Read MCP resource
714
+ * @param {Project} project - the project model instance
715
+ * @param {string|McpEndpointSpec} endpoint - MCP endpoint to call.
716
+ * @param {string} uri - URI of the MCP resource to read
717
+ * @returns {Object} MCP resource result
718
+ */
719
+ readMCPResource: async (project, endpoint, uri) => {
720
+ const cachedProject = await this._projects.get(project.id)
721
+ if (cachedProject === undefined) {
722
+ throw new Error('Instance cannot read MCP resource')
723
+ }
724
+ const port = await project.getSetting('port')
725
+ try {
726
+ const response = await got.post('http://localhost:' + (port + 1000) + '/flowforge/command', {
727
+ json: {
728
+ cmd: 'mcp:read-resource',
729
+ data: {
730
+ endpoint,
731
+ uri
732
+ }
733
+ }
734
+ }).json()
735
+ return response
736
+ } catch (error) {
737
+ throw new Error(`Failed to read MCP resource: ${error.message}`)
738
+ }
739
+ },
740
+
741
+ // #endregion MCP Support
742
+
633
743
  /**
634
744
  * Logout Node-RED instance
635
745
  * @param {Project} project - the project model instance
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowfuse/driver-localfs",
3
- "version": "2.31.4-c7f2d76-202606302009.0",
3
+ "version": "2.32.0",
4
4
  "description": "Local Filesystem FlowFuse Project driver",
5
5
  "main": "localfs.js",
6
6
  "scripts": {
@@ -22,7 +22,7 @@
22
22
  "license": "Apache-2.0",
23
23
  "dependencies": {
24
24
  "@flowfuse/mqtt-schema-agent": "^1.1.1",
25
- "@flowfuse/nr-launcher": "2.31.4-5ccdf52-202606302008.0",
25
+ "@flowfuse/nr-launcher": "^2.32.0",
26
26
  "form-data": "^4.0.0",
27
27
  "got": "^11.8.5",
28
28
  "semver": "~7.6.0",