proprioceptive-mcp 0.1.0__tar.gz

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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Proprioceptive AI, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,104 @@
1
+ Metadata-Version: 2.4
2
+ Name: proprioceptive-mcp
3
+ Version: 0.1.0
4
+ Summary: MCP server for Claude Code, Cursor and other agents: ask your local model (Ollama) and see how sure it was about every word.
5
+ Author-email: Proprioceptive AI <logan@proprioceptiveai.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://proprioceptiveai.com/products.html
8
+ Project-URL: Repository, https://github.com/Loganwins/proprioceptive-confidence
9
+ Project-URL: Issues, https://github.com/Loganwins/proprioceptive-confidence/issues
10
+ Project-URL: Proprioceptive Lens, https://pypi.org/project/proprioceptive-lens/
11
+ Keywords: mcp,model-context-protocol,mcp-server,ollama,local-llm,claude-code,cursor,confidence,logprobs
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
17
+ Requires-Python: >=3.10
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: mcp<3,>=2.3
21
+ Requires-Dist: proprioceptive-confidence>=0.1.0
22
+ Requires-Dist: typing-extensions>=4.7
23
+ Dynamic: license-file
24
+
25
+ # proprioceptive-mcp
26
+
27
+ **Let Claude Code, Cursor and other agents ask your local model, and see how sure it was.**
28
+
29
+ An MCP server that connects any MCP-capable agent to the model running on your own machine (Ollama, or any
30
+ OpenAI-compatible server that returns token probabilities). Every answer comes back with how sure the model was
31
+ about each word, the words it hesitated on, and, for shaky short answers, whether the answer held up when
32
+ re-asked in full.
33
+
34
+ <!-- mcp-name: io.github.Loganwins/proprioceptive-mcp -->
35
+
36
+ ## Install
37
+
38
+ **Claude Code**
39
+
40
+ ```
41
+ claude mcp add proprioceptive -- uvx proprioceptive-mcp
42
+ ```
43
+
44
+ **Cursor, Claude Desktop and other clients** (`mcp.json` / `claude_desktop_config.json`):
45
+
46
+ ```json
47
+ {
48
+ "mcpServers": {
49
+ "proprioceptive": {
50
+ "command": "uvx",
51
+ "args": ["proprioceptive-mcp", "--model", "llama3.2"]
52
+ }
53
+ }
54
+ }
55
+ ```
56
+
57
+ Or `pip install proprioceptive-mcp` and use `"command": "proprioceptive-mcp"`.
58
+
59
+ You need a local model server: [Ollama](https://ollama.com) 0.12 or later (`ollama pull llama3.2`), or any
60
+ OpenAI-compatible server that returns logprobs (`--api openai --base-url http://127.0.0.1:8000/v1`).
61
+
62
+ ## Tools
63
+
64
+ | Tool | What it does |
65
+ |---|---|
66
+ | `ask_local_model` | Asks your local model. Returns the answer, `confident` or `shaky`, the lowest word probability, the shaky words with alternatives, and a double-check for shaky short answers. |
67
+ | `list_local_models` | Lists the models your local server can run. |
68
+
69
+ Example result:
70
+
71
+ ```json
72
+ {
73
+ "answer": "1904",
74
+ "verdict": "shaky",
75
+ "summary": "shaky: 1 word(s) below 80%: \"190\" at 66%",
76
+ "double_check": {"second_answer": "Albert Einstein was born in 1879.", "agrees": false}
77
+ }
78
+ ```
79
+
80
+ *(Illustrative; real numbers depend on your model.)*
81
+
82
+ ## Settings
83
+
84
+ | Flag | Environment | Default |
85
+ |---|---|---|
86
+ | `--model` | `PCONF_MODEL` | `llama3.2` |
87
+ | `--api` | `PCONF_API` | `ollama` |
88
+ | `--base-url` | `PCONF_BASE_URL` | `$OLLAMA_HOST` or `http://127.0.0.1:11434` |
89
+ | `--threshold` | `PCONF_THRESHOLD` | `0.8` |
90
+
91
+ Everything runs on your machine: the server only talks to the model server address you give it.
92
+
93
+ ## What it can't do
94
+
95
+ A model can be wrong and certain. Token probabilities catch *shaky* answers, not confident mistakes.
96
+
97
+ ## Related
98
+
99
+ - **proprioceptive-confidence**: the library underneath, with LangChain and LiteLLM adapters.
100
+ - **pytest-llm-confidence**: fail a test when the model wasn't sure of its answer.
101
+ - **Proprioceptive Lens**: the full local app, with live confidence colouring, memory and internal-state
102
+ behaviour readings: `pip install proprioceptive-lens`.
103
+
104
+ MIT licensed. From [Proprioceptive AI](https://proprioceptiveai.com).
@@ -0,0 +1,80 @@
1
+ # proprioceptive-mcp
2
+
3
+ **Let Claude Code, Cursor and other agents ask your local model, and see how sure it was.**
4
+
5
+ An MCP server that connects any MCP-capable agent to the model running on your own machine (Ollama, or any
6
+ OpenAI-compatible server that returns token probabilities). Every answer comes back with how sure the model was
7
+ about each word, the words it hesitated on, and, for shaky short answers, whether the answer held up when
8
+ re-asked in full.
9
+
10
+ <!-- mcp-name: io.github.Loganwins/proprioceptive-mcp -->
11
+
12
+ ## Install
13
+
14
+ **Claude Code**
15
+
16
+ ```
17
+ claude mcp add proprioceptive -- uvx proprioceptive-mcp
18
+ ```
19
+
20
+ **Cursor, Claude Desktop and other clients** (`mcp.json` / `claude_desktop_config.json`):
21
+
22
+ ```json
23
+ {
24
+ "mcpServers": {
25
+ "proprioceptive": {
26
+ "command": "uvx",
27
+ "args": ["proprioceptive-mcp", "--model", "llama3.2"]
28
+ }
29
+ }
30
+ }
31
+ ```
32
+
33
+ Or `pip install proprioceptive-mcp` and use `"command": "proprioceptive-mcp"`.
34
+
35
+ You need a local model server: [Ollama](https://ollama.com) 0.12 or later (`ollama pull llama3.2`), or any
36
+ OpenAI-compatible server that returns logprobs (`--api openai --base-url http://127.0.0.1:8000/v1`).
37
+
38
+ ## Tools
39
+
40
+ | Tool | What it does |
41
+ |---|---|
42
+ | `ask_local_model` | Asks your local model. Returns the answer, `confident` or `shaky`, the lowest word probability, the shaky words with alternatives, and a double-check for shaky short answers. |
43
+ | `list_local_models` | Lists the models your local server can run. |
44
+
45
+ Example result:
46
+
47
+ ```json
48
+ {
49
+ "answer": "1904",
50
+ "verdict": "shaky",
51
+ "summary": "shaky: 1 word(s) below 80%: \"190\" at 66%",
52
+ "double_check": {"second_answer": "Albert Einstein was born in 1879.", "agrees": false}
53
+ }
54
+ ```
55
+
56
+ *(Illustrative; real numbers depend on your model.)*
57
+
58
+ ## Settings
59
+
60
+ | Flag | Environment | Default |
61
+ |---|---|---|
62
+ | `--model` | `PCONF_MODEL` | `llama3.2` |
63
+ | `--api` | `PCONF_API` | `ollama` |
64
+ | `--base-url` | `PCONF_BASE_URL` | `$OLLAMA_HOST` or `http://127.0.0.1:11434` |
65
+ | `--threshold` | `PCONF_THRESHOLD` | `0.8` |
66
+
67
+ Everything runs on your machine: the server only talks to the model server address you give it.
68
+
69
+ ## What it can't do
70
+
71
+ A model can be wrong and certain. Token probabilities catch *shaky* answers, not confident mistakes.
72
+
73
+ ## Related
74
+
75
+ - **proprioceptive-confidence**: the library underneath, with LangChain and LiteLLM adapters.
76
+ - **pytest-llm-confidence**: fail a test when the model wasn't sure of its answer.
77
+ - **Proprioceptive Lens**: the full local app, with live confidence colouring, memory and internal-state
78
+ behaviour readings: `pip install proprioceptive-lens`.
79
+
80
+ MIT licensed. From [Proprioceptive AI](https://proprioceptiveai.com).
@@ -0,0 +1,34 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "proprioceptive-mcp"
7
+ version = "0.1.0"
8
+ description = "MCP server for Claude Code, Cursor and other agents: ask your local model (Ollama) and see how sure it was about every word."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ dependencies = ["mcp>=2.3,<3", "proprioceptive-confidence>=0.1.0", "typing-extensions>=4.7"]
12
+ license = "MIT"
13
+ license-files = ["LICENSE"]
14
+ authors = [{ name = "Proprioceptive AI", email = "logan@proprioceptiveai.com" }]
15
+ keywords = ["mcp", "model-context-protocol", "mcp-server", "ollama", "local-llm", "claude-code", "cursor", "confidence", "logprobs"]
16
+ classifiers = [
17
+ "Development Status :: 4 - Beta",
18
+ "Intended Audience :: Developers",
19
+ "Programming Language :: Python :: 3",
20
+ "Operating System :: OS Independent",
21
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
22
+ ]
23
+
24
+ [project.urls]
25
+ Homepage = "https://proprioceptiveai.com/products.html"
26
+ Repository = "https://github.com/Loganwins/proprioceptive-confidence"
27
+ Issues = "https://github.com/Loganwins/proprioceptive-confidence/issues"
28
+ "Proprioceptive Lens" = "https://pypi.org/project/proprioceptive-lens/"
29
+
30
+ [project.scripts]
31
+ proprioceptive-mcp = "proprioceptive_mcp.server:main"
32
+
33
+ [tool.setuptools.packages.find]
34
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,6 @@
1
+ """proprioceptive-mcp: let Claude Code, Cursor and other agents ask your local model and see how sure it was.
2
+
3
+ From Proprioceptive AI (https://proprioceptiveai.com).
4
+ """
5
+
6
+ __version__ = "0.1.0"
@@ -0,0 +1,5 @@
1
+ import sys
2
+
3
+ from .server import main
4
+
5
+ sys.exit(main())
@@ -0,0 +1,198 @@
1
+ """proprioceptive-mcp: an MCP server that lets agents ask your local model and see how sure it was.
2
+
3
+ Tools:
4
+ ask_local_model ask the local model a question; returns the answer, how sure the model was about
5
+ each word, the shaky words, and (for shaky short answers) a double-check
6
+ list_local_models list the models your local server can run
7
+
8
+ Configuration (environment variables or command-line flags):
9
+ PCONF_MODEL default model (llama3.2)
10
+ PCONF_API ollama (default) or openai
11
+ PCONF_BASE_URL server address (default $OLLAMA_HOST or http://127.0.0.1:11434)
12
+ PCONF_THRESHOLD probability below which a word counts as shaky (0.8)
13
+ """
14
+
15
+ from __future__ import annotations
16
+
17
+ import os
18
+ from typing import Any, Callable, Dict, List, Optional
19
+
20
+ from typing_extensions import NotRequired, TypedDict
21
+
22
+ from mcp.server.mcpserver import MCPServer
23
+ from mcp.server.mcpserver.exceptions import ToolError
24
+ from mcp.types import ToolAnnotations
25
+
26
+ from proprioceptive_confidence import DEFAULT_THRESHOLD, ConfidenceClient, ConfidenceError
27
+
28
+ from . import __version__
29
+
30
+ INSTRUCTIONS = (
31
+ "This server connects you to the user's own local language model (usually through Ollama) and reports how "
32
+ "sure that model was about every word of its answer, from its token probabilities. Use ask_local_model when "
33
+ "the user wants a local or private second opinion, or wants to compare your answer with their local model. "
34
+ "Read the result as follows: 'confident' means every word was above the threshold; 'shaky' lists the words the "
35
+ "model hesitated on. A double-check that disagrees means the short answer did not hold up when re-asked in "
36
+ "full. High confidence is not proof of correctness: models can be confidently wrong."
37
+ )
38
+
39
+ LENS_NOTE = "See this live in a local app, with memory and internal-state readings: pip install proprioceptive-lens"
40
+
41
+ ClientFactory = Callable[[], ConfidenceClient]
42
+
43
+
44
+ class Alternative(TypedDict):
45
+ text: str
46
+ prob: float
47
+
48
+
49
+ class ShakyWord(TypedDict):
50
+ text: str
51
+ prob: float
52
+ alternatives: List[Alternative]
53
+
54
+
55
+ class DoubleCheckResult(TypedDict):
56
+ second_answer: str
57
+ agrees: bool
58
+ second_summary: str
59
+
60
+
61
+ class AskResult(TypedDict):
62
+ answer: str
63
+ model: str
64
+ verdict: str
65
+ summary: str
66
+ threshold: float
67
+ min_prob: float
68
+ mean_prob: float
69
+ shaky_words: List[ShakyWord]
70
+ note: str
71
+ more: str
72
+ double_check: NotRequired[DoubleCheckResult]
73
+
74
+
75
+ class ModelList(TypedDict):
76
+ server: str
77
+ api: str
78
+ default_model: str
79
+ models: List[str]
80
+
81
+
82
+ def _env_float(name: str, default: float) -> float:
83
+ try:
84
+ return float(os.environ.get(name, default))
85
+ except ValueError:
86
+ return default
87
+
88
+
89
+ def default_client() -> ConfidenceClient:
90
+ return ConfidenceClient(threshold=_env_float("PCONF_THRESHOLD", DEFAULT_THRESHOLD))
91
+
92
+
93
+ def build_server(client_factory: Optional[ClientFactory] = None) -> MCPServer:
94
+ make_client = client_factory or default_client
95
+
96
+ server = MCPServer(
97
+ name="proprioceptive",
98
+ title="Proprioceptive: local model confidence",
99
+ description="Ask your local model and see how sure it was about every word.",
100
+ instructions=INSTRUCTIONS,
101
+ website_url="https://proprioceptiveai.com",
102
+ version=__version__,
103
+ )
104
+
105
+ @server.tool(
106
+ name="ask_local_model",
107
+ title="Ask the local model",
108
+ description=(
109
+ "Ask the user's local language model a question. Returns its answer, how sure it was about each word, "
110
+ "the words it hesitated on, and, for shaky short answers, whether the answer held up when re-asked in full."
111
+ ),
112
+ annotations=ToolAnnotations(read_only_hint=True, open_world_hint=False, idempotent_hint=True),
113
+ )
114
+ def ask_local_model(
115
+ prompt: str,
116
+ model: Optional[str] = None,
117
+ double_check: bool = True,
118
+ threshold: Optional[float] = None,
119
+ ) -> AskResult:
120
+ """Ask the local model and report its confidence.
121
+
122
+ Args:
123
+ prompt: the question or instruction for the local model.
124
+ model: model name, e.g. "llama3.2" or "qwen3:4b". Defaults to the server's configured model.
125
+ double_check: re-ask shaky short answers in full and report whether they agree.
126
+ threshold: probability (0 to 1) below which a word counts as shaky. Default 0.8.
127
+ """
128
+ client = make_client()
129
+ if threshold is not None:
130
+ if not 0.0 < threshold <= 1.0:
131
+ raise ToolError("threshold must be between 0 and 1")
132
+ client.threshold = threshold
133
+ try:
134
+ ans = client.ask(prompt, model=model, double_check=double_check)
135
+ except ConfidenceError as exc:
136
+ raise ToolError(
137
+ f"{exc}. Is your local model server running? For Ollama: `ollama serve`, then `ollama pull {model or client.model}`."
138
+ ) from exc
139
+ rep = ans.report
140
+ result: AskResult = {
141
+ "answer": ans.text,
142
+ "model": ans.model,
143
+ "verdict": "confident" if rep.is_confident else "shaky",
144
+ "summary": rep.summary(),
145
+ "threshold": rep.threshold,
146
+ "min_prob": round(rep.min_prob, 4),
147
+ "mean_prob": round(rep.mean_prob, 4),
148
+ "shaky_words": [
149
+ {"text": t.text.strip(), "prob": round(t.prob, 4),
150
+ "alternatives": [{"text": a.strip(), "prob": round(p, 4)} for a, p in t.alternatives if a != t.text][:3]}
151
+ for t in sorted(rep.shaky, key=lambda t: t.prob)[:10]
152
+ ],
153
+ "note": "Token probabilities catch shaky answers, not confident mistakes.",
154
+ "more": LENS_NOTE,
155
+ }
156
+ if ans.double_check is not None:
157
+ dc = ans.double_check
158
+ result["double_check"] = {
159
+ "second_answer": dc.second_answer,
160
+ "agrees": dc.agrees,
161
+ "second_summary": dc.report.summary(),
162
+ }
163
+ return result
164
+
165
+ @server.tool(
166
+ name="list_local_models",
167
+ title="List local models",
168
+ description="List the models the user's local model server can run.",
169
+ annotations=ToolAnnotations(read_only_hint=True, open_world_hint=False, idempotent_hint=True),
170
+ )
171
+ def list_local_models() -> ModelList:
172
+ """List models available on the local model server."""
173
+ client = make_client()
174
+ try:
175
+ models = client.list_models()
176
+ except ConfidenceError as exc:
177
+ raise ToolError(f"{exc}. Is your local model server running? For Ollama: `ollama serve`.") from exc
178
+ return {"server": client.base_url, "api": client.api, "default_model": client.model, "models": models}
179
+
180
+ return server
181
+
182
+
183
+ def main(argv: Optional[list] = None) -> int:
184
+ import argparse
185
+
186
+ ap = argparse.ArgumentParser(prog="proprioceptive-mcp", description="MCP server: ask your local model and see how sure it was.")
187
+ ap.add_argument("--model", help="default model (env PCONF_MODEL, default llama3.2)")
188
+ ap.add_argument("--api", choices=["ollama", "openai"], help="server type (env PCONF_API, default ollama)")
189
+ ap.add_argument("--base-url", help="model server address (env PCONF_BASE_URL)")
190
+ ap.add_argument("--threshold", type=float, help="shaky-word threshold (env PCONF_THRESHOLD, default 0.8)")
191
+ ap.add_argument("--version", action="version", version=f"proprioceptive-mcp {__version__}")
192
+ args = ap.parse_args(argv)
193
+ for flag, env in (("model", "PCONF_MODEL"), ("api", "PCONF_API"), ("base_url", "PCONF_BASE_URL"), ("threshold", "PCONF_THRESHOLD")):
194
+ val = getattr(args, flag)
195
+ if val is not None:
196
+ os.environ[env] = str(val)
197
+ build_server().run("stdio")
198
+ return 0
@@ -0,0 +1,104 @@
1
+ Metadata-Version: 2.4
2
+ Name: proprioceptive-mcp
3
+ Version: 0.1.0
4
+ Summary: MCP server for Claude Code, Cursor and other agents: ask your local model (Ollama) and see how sure it was about every word.
5
+ Author-email: Proprioceptive AI <logan@proprioceptiveai.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://proprioceptiveai.com/products.html
8
+ Project-URL: Repository, https://github.com/Loganwins/proprioceptive-confidence
9
+ Project-URL: Issues, https://github.com/Loganwins/proprioceptive-confidence/issues
10
+ Project-URL: Proprioceptive Lens, https://pypi.org/project/proprioceptive-lens/
11
+ Keywords: mcp,model-context-protocol,mcp-server,ollama,local-llm,claude-code,cursor,confidence,logprobs
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
17
+ Requires-Python: >=3.10
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: mcp<3,>=2.3
21
+ Requires-Dist: proprioceptive-confidence>=0.1.0
22
+ Requires-Dist: typing-extensions>=4.7
23
+ Dynamic: license-file
24
+
25
+ # proprioceptive-mcp
26
+
27
+ **Let Claude Code, Cursor and other agents ask your local model, and see how sure it was.**
28
+
29
+ An MCP server that connects any MCP-capable agent to the model running on your own machine (Ollama, or any
30
+ OpenAI-compatible server that returns token probabilities). Every answer comes back with how sure the model was
31
+ about each word, the words it hesitated on, and, for shaky short answers, whether the answer held up when
32
+ re-asked in full.
33
+
34
+ <!-- mcp-name: io.github.Loganwins/proprioceptive-mcp -->
35
+
36
+ ## Install
37
+
38
+ **Claude Code**
39
+
40
+ ```
41
+ claude mcp add proprioceptive -- uvx proprioceptive-mcp
42
+ ```
43
+
44
+ **Cursor, Claude Desktop and other clients** (`mcp.json` / `claude_desktop_config.json`):
45
+
46
+ ```json
47
+ {
48
+ "mcpServers": {
49
+ "proprioceptive": {
50
+ "command": "uvx",
51
+ "args": ["proprioceptive-mcp", "--model", "llama3.2"]
52
+ }
53
+ }
54
+ }
55
+ ```
56
+
57
+ Or `pip install proprioceptive-mcp` and use `"command": "proprioceptive-mcp"`.
58
+
59
+ You need a local model server: [Ollama](https://ollama.com) 0.12 or later (`ollama pull llama3.2`), or any
60
+ OpenAI-compatible server that returns logprobs (`--api openai --base-url http://127.0.0.1:8000/v1`).
61
+
62
+ ## Tools
63
+
64
+ | Tool | What it does |
65
+ |---|---|
66
+ | `ask_local_model` | Asks your local model. Returns the answer, `confident` or `shaky`, the lowest word probability, the shaky words with alternatives, and a double-check for shaky short answers. |
67
+ | `list_local_models` | Lists the models your local server can run. |
68
+
69
+ Example result:
70
+
71
+ ```json
72
+ {
73
+ "answer": "1904",
74
+ "verdict": "shaky",
75
+ "summary": "shaky: 1 word(s) below 80%: \"190\" at 66%",
76
+ "double_check": {"second_answer": "Albert Einstein was born in 1879.", "agrees": false}
77
+ }
78
+ ```
79
+
80
+ *(Illustrative; real numbers depend on your model.)*
81
+
82
+ ## Settings
83
+
84
+ | Flag | Environment | Default |
85
+ |---|---|---|
86
+ | `--model` | `PCONF_MODEL` | `llama3.2` |
87
+ | `--api` | `PCONF_API` | `ollama` |
88
+ | `--base-url` | `PCONF_BASE_URL` | `$OLLAMA_HOST` or `http://127.0.0.1:11434` |
89
+ | `--threshold` | `PCONF_THRESHOLD` | `0.8` |
90
+
91
+ Everything runs on your machine: the server only talks to the model server address you give it.
92
+
93
+ ## What it can't do
94
+
95
+ A model can be wrong and certain. Token probabilities catch *shaky* answers, not confident mistakes.
96
+
97
+ ## Related
98
+
99
+ - **proprioceptive-confidence**: the library underneath, with LangChain and LiteLLM adapters.
100
+ - **pytest-llm-confidence**: fail a test when the model wasn't sure of its answer.
101
+ - **Proprioceptive Lens**: the full local app, with live confidence colouring, memory and internal-state
102
+ behaviour readings: `pip install proprioceptive-lens`.
103
+
104
+ MIT licensed. From [Proprioceptive AI](https://proprioceptiveai.com).
@@ -0,0 +1,13 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/proprioceptive_mcp/__init__.py
5
+ src/proprioceptive_mcp/__main__.py
6
+ src/proprioceptive_mcp/server.py
7
+ src/proprioceptive_mcp.egg-info/PKG-INFO
8
+ src/proprioceptive_mcp.egg-info/SOURCES.txt
9
+ src/proprioceptive_mcp.egg-info/dependency_links.txt
10
+ src/proprioceptive_mcp.egg-info/entry_points.txt
11
+ src/proprioceptive_mcp.egg-info/requires.txt
12
+ src/proprioceptive_mcp.egg-info/top_level.txt
13
+ tests/test_server.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ proprioceptive-mcp = proprioceptive_mcp.server:main
@@ -0,0 +1,3 @@
1
+ mcp<3,>=2.3
2
+ proprioceptive-confidence>=0.1.0
3
+ typing-extensions>=4.7
@@ -0,0 +1 @@
1
+ proprioceptive_mcp
@@ -0,0 +1,123 @@
1
+ import json
2
+ import os
3
+ import sys
4
+
5
+ import anyio
6
+ import pytest
7
+
8
+ from mcp import Client, StdioServerParameters
9
+
10
+ from proprioceptive_confidence import ConfidenceClient
11
+ from proprioceptive_confidence.testing import FakeModelServer
12
+ from proprioceptive_mcp.server import build_server
13
+
14
+ ANSWERS = {
15
+ "complete sentence": [("Albert", 0.99), (" Einstein", 0.99), (" was", 0.99), (" born", 0.99), (" in", 0.99), (" 1879", 0.95), (".", 0.99)],
16
+ "einstein": [("190", 0.66), ("4", 0.97)],
17
+ "france": [("Paris", 0.98)],
18
+ }
19
+
20
+
21
+ def _payload(result):
22
+ if getattr(result, "structured_content", None):
23
+ return result.structured_content
24
+ text = "".join(getattr(c, "text", "") for c in result.content)
25
+ return json.loads(text)
26
+
27
+
28
+ @pytest.fixture
29
+ def fake():
30
+ with FakeModelServer(answers=ANSWERS) as srv:
31
+ yield srv
32
+
33
+
34
+ def test_tools_listed_with_read_only_annotations(fake):
35
+ server = build_server(lambda: ConfidenceClient(base_url=fake.url))
36
+
37
+ async def go():
38
+ async with Client(server) as client:
39
+ tools = (await client.list_tools()).tools
40
+ return {t.name: t for t in tools}
41
+
42
+ tools = anyio.run(go)
43
+ assert set(tools) == {"ask_local_model", "list_local_models"}
44
+ assert tools["ask_local_model"].annotations.read_only_hint is True
45
+ assert "prompt" in tools["ask_local_model"].input_schema["properties"]
46
+
47
+
48
+ def test_ask_shaky_answer_with_double_check(fake):
49
+ server = build_server(lambda: ConfidenceClient(base_url=fake.url))
50
+
51
+ async def go():
52
+ async with Client(server) as client:
53
+ return await client.call_tool("ask_local_model", {"prompt": "In what year was Albert Einstein born?"})
54
+
55
+ res = anyio.run(go)
56
+ assert not res.is_error
57
+ data = _payload(res)
58
+ assert data["answer"] == "1904"
59
+ assert data["verdict"] == "shaky"
60
+ assert data["shaky_words"][0]["text"] == "190"
61
+ assert data["double_check"]["agrees"] is False
62
+ assert "proprioceptive-lens" in data["more"]
63
+
64
+
65
+ def test_ask_confident_and_threshold_validation(fake):
66
+ server = build_server(lambda: ConfidenceClient(base_url=fake.url))
67
+
68
+ async def go():
69
+ async with Client(server) as client:
70
+ ok = await client.call_tool("ask_local_model", {"prompt": "Capital of France?"})
71
+ bad = await client.call_tool("ask_local_model", {"prompt": "x", "threshold": 5})
72
+ return ok, bad
73
+
74
+ ok, bad = anyio.run(go)
75
+ assert _payload(ok)["verdict"] == "confident" and "double_check" not in _payload(ok)
76
+ assert bad.is_error
77
+
78
+
79
+ def test_list_models_and_unreachable_server(fake):
80
+ good = build_server(lambda: ConfidenceClient(base_url=fake.url))
81
+ down = build_server(lambda: ConfidenceClient(base_url="http://127.0.0.1:9", timeout=2))
82
+
83
+ async def go():
84
+ async with Client(good) as c1:
85
+ listed = await c1.call_tool("list_local_models", {})
86
+ async with Client(down) as c2:
87
+ failed = await c2.call_tool("ask_local_model", {"prompt": "hi"})
88
+ return listed, failed
89
+
90
+ listed, failed = anyio.run(go)
91
+ assert "llama3.2" in _payload(listed)["models"]
92
+ assert failed.is_error
93
+ assert "ollama serve" in "".join(getattr(c, "text", "") for c in failed.content)
94
+
95
+
96
+ def test_runs_over_stdio_as_a_real_subprocess(fake):
97
+ env = dict(os.environ, PCONF_BASE_URL=fake.url, PCONF_MODEL="llama3.2")
98
+ params = StdioServerParameters(command=sys.executable, args=["-m", "proprioceptive_mcp"], env=env)
99
+
100
+ async def go():
101
+ async with Client(params) as client:
102
+ names = [t.name for t in (await client.list_tools()).tools]
103
+ res = await client.call_tool("ask_local_model", {"prompt": "Capital of France?", "double_check": False})
104
+ return names, res, client.server_info, client.protocol_version
105
+
106
+ names, res, info, version = anyio.run(go)
107
+ assert "ask_local_model" in names
108
+ assert _payload(res)["answer"] == "Paris"
109
+ assert info.name == "proprioceptive"
110
+ assert version # negotiated protocol version
111
+
112
+
113
+ def test_older_clients_on_the_2025_handshake_still_work(fake):
114
+ env = dict(os.environ, PCONF_BASE_URL=fake.url)
115
+ params = StdioServerParameters(command=sys.executable, args=["-m", "proprioceptive_mcp"], env=env)
116
+
117
+ async def go():
118
+ async with Client(params, mode="legacy") as client:
119
+ res = await client.call_tool("ask_local_model", {"prompt": "Capital of France?", "double_check": False})
120
+ return client.protocol_version, _payload(res)["answer"]
121
+
122
+ version, answer = anyio.run(go)
123
+ assert version.startswith("2025") and answer == "Paris"