SimpleSallap:SimpleMCP:Cleanup, rename; TestMcpCmdline helper

Given toolcall.py maintains ToolCall, ToolManager and MCP related
types and base classes, so rename to toolcalls.py

Also add the bash script with curl used for testing the tools/list
mcp command.

Remove the sample function meta ref, as tools/list is working ok.
This commit is contained in:
hanishkvc 2025-12-07 19:52:42 +05:30
parent f75f93f8d9
commit 37651dc7dd
8 changed files with 21 additions and 35 deletions

View File

@ -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

View File

@ -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' ]

View File

@ -4,7 +4,7 @@
import urllib.request
import urllib.parse
import debug
import toolcall as mTC
import toolcalls as mTC
from dataclasses import dataclass

View File

@ -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

View File

@ -3,7 +3,7 @@
import urlvalidator as uv
import filemagic as mFile
import toolcall as mTC
import toolcalls as mTC
from typing import Any

View File

@ -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

View File

@ -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

View File

@ -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: