PythonLibCore icon indicating copy to clipboard operation
PythonLibCore copied to clipboard

The use of robotlibraries as mcp server

Open noubar opened this issue 8 months ago • 0 comments

There are several robotlibraries implementet which provide to robot additional functionalies (keywords). Those same keywords are potential candidates to be used as mcp.tools. Why should we implement the same functionality twice let us use already implemented robot libraries as mcp servers.

Here is a very simple example:

from mcp.server.fastmcp import FastMCP

    def to_mcp(self):
        mcp = FastMCP(self.__class__.__name__)
        for kw in self.keywords.values():
            mcp.add_tool(kw)
        return mcp

i have added these lines in the class after init of an implemented library https://github.com/noubar/RobotFramework-MailClientLibrary/blob/55d63296c7e96236041f0ae3310a8bb0f141b3e6/src/MailClientLibrary/init.py#L90

this funcionality could also be directly added to the implementation of hybric core https://github.com/robotframework/PythonLibCore/blob/90a62a07cc03c6760b68a5c797c2572c13a757b9/src/robotlibcore/core/hybrid.py#L121

To run the server localy

from src.MailClientLibrary import MailClientLibrary 
a = MailClientLibrary().to_mcp()
a.run(transport='stdio')

And here it is running under vscode insiders version because the relaese version does not have the functionality yet

Image

noubar avatar Mar 30 '25 15:03 noubar