Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
create an MCP server that can accept calls from AI agent tools like n8n?
#1
n8n is an open-source AI agent workflow development tool, but its capability to operate on the computer's underlying system is limited. Could we use LA to extend its functionality?
https://github.com/n8n-io/n8n

Relevant resources
https://github.com/punkpeye/awesome-mcp-servers
#2
Using LA as the MCP service for AI agents like n8n would be a great choice.
Currently, I can only invoke functions in LA by sending HTTP requests, which isn't very elegant.
If there were a template for creating MCP-based services, it would be much more convenient.
#3
MCP server example in LA.
The code is from https://devblogs.microsoft.com/blog/micr...t-protocol
 
Code:
Copy      Help
// script "MCP_server.cs"
/*/ role exeProgram; outputPath %folders.Workspace%\exe\MCP_server; console true; nuget mcp\ModelContextProtocol; nuget mcp\Microsoft.Extensions.Hosting; /*/

using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using ModelContextProtocol.Server;
using System.ComponentModel;

print.ignoreConsole = true;

//workaround for: does not find assemblies in runtimes\win\lib\net9.0
System.Runtime.Loader.AssemblyLoadContext.Default.Resolving += (o, e) => o.LoadFromAssemblyPath(folders.ThisAppBS + $@"runtimes\win\lib\net9.0\{e.Name}.dll");

try {
    var builder = Host.CreateApplicationBuilder(args);
    builder.Logging.AddConsole();
    
    builder.Services
        .AddMcpServer()
        .WithStdioServerTransport()
        .WithToolsFromAssembly();
    
    builder.Build().Run();
}

catch (Exception ex) { print.it(ex); }

/// <summary>
///
Add your functions to this class like the example. They will be automatically used as MCP tools by MCP clients.
/// </summary>
[McpServerToolType]
public static class EchoTool {
    [
McpServerTool, Description("Echoes the message back to the client.")]
    public static string Echo(string message) => $"Hello from C#: {message}";
}

Compile. Copy full path of the exe file. Paste in Command field in MCP client settings (more info below). MCP client will run the exe.

To use in n8n, need the community MCP Client, not the built-in MCP Client. And locally installed n8n, not the cloud n8n.

n8n MCP Client node fields for testing this MCP server:
- Credentials: create credential where Command is full path of your exe file created when you compile the example script. Later just select the credential.
- Tool Name: Echo
- Tool Parameters: {"message":"test"}.
#4
This is cool! But it's also hard to understand. Big Grin
#5
Thank you for your sharing. It looks a bit complex.

Both N8N and LA are open-source projects. It would be fantastic if we could integrate these two.  N8N + LA = Ai Workflow + RPA  Smile

Here’s my idea:
Create two projects:
  1. LA for n8n node MCP server, implemented on LA. It can retrieve all scripts or function parameters and descriptions from LA.The functionality in the link below might be useful.
    Call C# functions from anywhere using URL (HTTP server)
  2. LA for n8n node MCP client, which involves creating a community node for n8n. It can send parameters to the MCP server and retrieve execution results as needed, similar to the functionality of the project below.
    https://github.com/nerding-io/n8n-nodes-mcp
LA makes the implementation of many features simpler and more elegant. It's time to add some AI capabilities to it—for example, enabling AI to automatically generate function descriptions or parameter documentation, which would be helpful for use in the above n8n project.


Forum Jump:


Users browsing this thread: 1 Guest(s)