diff --git a/tools/server/public_simplechat/docs/changelog.md b/tools/server/public_simplechat/docs/changelog.md index 644e76ee03..8cd4e121eb 100644 --- a/tools/server/public_simplechat/docs/changelog.md +++ b/tools/server/public_simplechat/docs/changelog.md @@ -319,10 +319,12 @@ Chat Session specific settings * switch to a Dicty DataClass based Config with better type validation and usage, instead of literal dict++ * ToolCall, ToolManager and related classes based flow wrt the tool calls. * all existing tool calls duplicated and updated to support and build on this new flow. -* Initial skeleton towards SimpleMCP, a post and json based handshake flow, so that the tool calls supported +* Initial skeleton towards SimpleMCP, a post and json rpcish based handshake flow, so that tool calls supported through SimpleProxy can be exposed through a MCP standardish mechanism. * can allow others beyond AnveshikaSallap client to use the corresponding tool calls * can allow AnveshikaSallap client to support other MCP servers and their exposed tool calls in future. + Mcp command tools/list implemented and verified at a basic level + Mcp command tools/call implemented, need to verify and update the initial go version ## ToDo diff --git a/tools/server/public_simplechat/local.tools/config.py b/tools/server/public_simplechat/local.tools/config.py index 74fcb2c9ef..448ec8bed5 100644 --- a/tools/server/public_simplechat/local.tools/config.py +++ b/tools/server/public_simplechat/local.tools/config.py @@ -9,7 +9,7 @@ import ssl import sys import urlvalidator as mUV import debug as mDebug -import toolcall as mTC +import toolcalls as mTC gConfigNeeded = [ 'acl.schemes', 'acl.domains', 'sec.bearerAuth' ] diff --git a/tools/server/public_simplechat/local.tools/filemagic.py b/tools/server/public_simplechat/local.tools/filemagic.py index 0bf3ce7e18..4ed834f8cf 100644 --- a/tools/server/public_simplechat/local.tools/filemagic.py +++ b/tools/server/public_simplechat/local.tools/filemagic.py @@ -4,7 +4,7 @@ import urllib.request import urllib.parse import debug -import toolcall as mTC +import toolcalls as mTC from dataclasses import dataclass diff --git a/tools/server/public_simplechat/local.tools/simplemcp.py b/tools/server/public_simplechat/local.tools/simplemcp.py index b3e5282040..0233c1f2ce 100644 --- a/tools/server/public_simplechat/local.tools/simplemcp.py +++ b/tools/server/public_simplechat/local.tools/simplemcp.py @@ -22,7 +22,7 @@ from typing import Any from dataclasses import asdict import tcpdf as mTCPdf import tcweb as mTCWeb -import toolcall as mTC +import toolcalls as mTC import config as mConfig diff --git a/tools/server/public_simplechat/local.tools/tcpdf.py b/tools/server/public_simplechat/local.tools/tcpdf.py index 572b05c288..a6103e1650 100644 --- a/tools/server/public_simplechat/local.tools/tcpdf.py +++ b/tools/server/public_simplechat/local.tools/tcpdf.py @@ -3,7 +3,7 @@ import urlvalidator as uv import filemagic as mFile -import toolcall as mTC +import toolcalls as mTC from typing import Any diff --git a/tools/server/public_simplechat/local.tools/tcweb.py b/tools/server/public_simplechat/local.tools/tcweb.py index d079fed94d..fe4b4239c3 100644 --- a/tools/server/public_simplechat/local.tools/tcweb.py +++ b/tools/server/public_simplechat/local.tools/tcweb.py @@ -8,7 +8,7 @@ import filemagic as mFile import json import re from typing import Any, cast -import toolcall as mTC +import toolcalls as mTC diff --git a/tools/server/public_simplechat/local.tools/test-mcp-cmdline.sh b/tools/server/public_simplechat/local.tools/test-mcp-cmdline.sh new file mode 100644 index 0000000000..d48ddeeb63 --- /dev/null +++ b/tools/server/public_simplechat/local.tools/test-mcp-cmdline.sh @@ -0,0 +1,10 @@ +echo "DONT FORGET TO RUN simplemcp.py with auth always disabled and in http mode" +echo "Note: sudo tcpdump -i lo -s 0 -vvv -A host 127.0.0.1 and port 3128 | tee /tmp/td.log can be used to capture the hs" +curl http://localhost:3128/mcp --trace - --header "Content-Type: application/json" -d '{ + "jsonrpc": "2.0", + "id": 2, + "method": "tools/list" +}' + +exit + diff --git a/tools/server/public_simplechat/local.tools/toolcall.py b/tools/server/public_simplechat/local.tools/toolcalls.py similarity index 74% rename from tools/server/public_simplechat/local.tools/toolcall.py rename to tools/server/public_simplechat/local.tools/toolcalls.py index 618b91182e..e11430936c 100644 --- a/tools/server/public_simplechat/local.tools/toolcall.py +++ b/tools/server/public_simplechat/local.tools/toolcalls.py @@ -1,4 +1,4 @@ -# Tool Call Base +# ToolCalls and MCP related types and bases # by Humans for All from typing import Any, TypeAlias @@ -6,29 +6,6 @@ from dataclasses import dataclass, field -# -# A sample tool call meta -# - -fetchurlraw_meta = { - "type": "function", - "function": { - "name": "fetch_url_raw", - "description": "Fetch contents of the requested url (local file path / web based) through a proxy server and return the got content as is, in few seconds. Mainly useful for getting textual non binary contents", - "parameters": { - "type": "object", - "properties": { - "url":{ - "type":"string", - "description":"url of the local file / web content to fetch" - } - }, - "required": ["url"] - } - } - } - - # # Dataclasses to help with Tool Calls # @@ -106,10 +83,6 @@ class ToolCall(): def tc_handle(self, args: TCInArgs, inHeaders: HttpHeaders) -> TCOutResponse: return TCOutResponse(False, 500) - def meta(self) -> ToolCallMeta: - tcf = self.tcf_meta() - return ToolCallMeta("function", tcf) - MCPTLTools: TypeAlias = list[ToolCallMeta] @@ -135,7 +108,8 @@ class ToolManager(): def meta(self): lMeta: MCPTLTools = [] for tcName in self.toolcalls.keys(): - lMeta.append(self.toolcalls[tcName].meta()) + tcfMeta = self.toolcalls[tcName].tcf_meta() + lMeta.append(ToolCallMeta("function", tcfMeta)) return lMeta def tc_handle(self, callId: str, tcName: str, tcArgs: TCInArgs, inHeaders: HttpHeaders) -> ToolCallResponseEx: