Add custom MCP profiles and reusable workspace libraries

This commit is contained in:
Mark Gregory
2026-11-16 14:50:20 +00:00
parent bc2ae8ec02
commit 32c4b9f91c
12 changed files with 1398 additions and 76 deletions
+106
View File
@@ -0,0 +1,106 @@
# Programming custom MCP servers for AI Studio
## Connect an existing server
Open **Toolbox** beside the composer. Choose **Use LM Studio Config** to read
`~/.lmstudio/mcp.json`, or **Import mcp.json** to choose another file. Select
a named server. For stdio, review and confirm process startup. For a URL,
choose **Discover Tools**. The composer shows the connected toolset and its tool
count. The connection stays active when you close Toolbox. Use **Disconnect**
to end it. AI Studio remembers the configuration file and the selected
profile. The source file remains your editable configuration.
A local profile accepts `command`, an `args` array, `env`, and an optional
absolute `cwd`. Each argument stays a separate string. No shell interprets the
config. Named commands resolve against PATH and common macOS binary folders.
For an ordinary `python` or `python3` command with an absolute script path,
AI Studio also checks for a nearby `.venv` unless the profile sets PATH.
Use an explicit virtual-environment executable for reproducibility.
A remote profile takes a Streamable HTTP `url` and optional `headers`.
Use HTTPS for remote hosts. HTTP is supported on loopback. Keep bearer
credentials in your selected file or in the manual session-only field.
Copy examples with placeholders and supply your own values locally.
```json
{
"mcpServers": {
"my-local-knowledge": {
"command": "/absolute/project/.venv/bin/python",
"args": ["-u", "/absolute/project/server.py"],
"cwd": "/absolute/project",
"env": { "PYTHONUNBUFFERED": "1" }
},
"my-remote-tools": {
"url": "https://tools.example.com/mcp",
"headers": { "Authorization": "Bearer YOUR_TOKEN" }
}
}
}
```
The attached archive's `src/knowledge_mcp.py` matches the installed
`local-knowledge` program. Select that profile to discover
`search_knowledge`, which accepts `query` and an optional `limit`. Run a query
in Toolbox, review the returned passages, then attach the result to chat.
The MCP index remains with its server. AI Studio's native **Knowledge Stacks**
can separately index files you import in Workspace.
## Implement a server
Use an official MCP SDK. For stdio, communicate in newline-delimited UTF-8
JSON-RPC on stdout and write logs on stderr. Support initialize, the initialized
notification, tools/list and tools/call. Return a JSON Schema object for each
tool's input, validate arguments server-side, and return structured output or
content entries. Paginate discovery with nextCursor if your listing is large.
A small Python example using the Python SDK's FastMCP interface:
```python
from mcp.server.fastmcp import FastMCP
server = FastMCP("Example reference tools")
@server.tool()
def lookup(term: str) -> str:
"""Return a short glossary entry."""
glossary = {"SQLite": "An embedded relational database."}
return glossary.get(term, "No matching entry.")
if __name__ == "__main__":
server.run(transport="stdio")
```
Use your virtual environment's Python and select the executable plus script
in an MCP profile. See the [MCP stdio and HTTP specification](https://modelcontextprotocol.io/specification/2025-11-25/basic/transports)
and the [LM Studio configuration format](https://lmstudio.ai/docs/app/mcp).
## Invoke and troubleshoot
- Select a discovered tool and inspect **Input Schema**. Enter JSON arguments
and confirm the call. Tool runs are manual. You can attach the resulting JSON
to the next reply in the active chat.
- **Executable unavailable:** set the absolute binary path or check the
profile's PATH. A GUI app may start with a different PATH than Terminal.
- **Configured script does not exist:** correct its path in the source
configuration and choose **Reload**. AI Studio cannot find files moved out
of a previous working directory.
- **Server closes or times out:** inspect the error and captured stderr.
Confirm the virtual environment has the dependencies. Keep startup banners
and logs off stdout. The stdio client waits 30 seconds per request.
- **HTTP 401/403:** check the configured authorization header and token.
Confirm that the URL is the MCP endpoint rather than the service homepage.
- **Discovery works but a tool fails:** compare your JSON with its input
schema and check the server's own logs. The app sends an invocation once.
The HTTP client supports legacy and stateless discovery. The stdio client
supports legacy protocol initialization. OAuth negotiation, server-requested
follow-up inputs, and automatic model-driven dispatch are outside this implementation.
### Existing Gitea profile
The older `absdev-gitea` launch script is absent from its configured path.
A separate GiteaMCP project uses Streamable HTTP. If you run that service,
add a named `url` profile with the endpoint it advertises and configure the
service's credentials locally. A Streamable HTTP process cannot be substituted
for the missing stdio script.
+18
View File
@@ -9,6 +9,7 @@
| 5. Generation and local tools | Awaiting Docker daemon check | Silent system instructions, runtime parameter overrides, confirmed Docker commands, Finder file actions |
| 6. Compatibility extensions | Awaiting live LM Studio check | OpenAI-compatible endpoint and MCP stdio |
| 7. Desktop and runtime controls | Complete | Selected-file previews and attachments, MLX idle eviction and weight limit |
| 8. Workspace and integration improvements | Baseline verified | LM Studio config import, Msty-style resource library and Toolbox, composer fixes, appearance, backups, registered MLX folders |
| Final external verification | Awaiting services and credentials | Live LM Studio, Docker, remote Ollama and MCP, Developer ID signing and notarization |
## Phase 6 checklist
@@ -35,6 +36,15 @@
- [x] Display generation histories, time to first output, wall-clock time, and provider-reported throughput.
- [x] Verify the workspace changes with XCTest, rebuild the app, and confirm the build launches.
## Workspace follow-ups
- [ ] Add Msty workspace migration, recovery scanning, and workspace relocation.
- [ ] Add editable shortcut bindings, additional chat appearance and rendering controls, and split-chat layouts.
- [ ] Extend Prompt Library metadata, version history, and authenticated or rendered web clip capture.
- [ ] Design ACP agent adapters, diff review, and tool history; integrate or configure a separate local proxy.
- [ ] Evaluate LM Studio runtime and plugin parity, including additional engines, runtime updates, and headless service controls.
- [ ] Verify the Gitea MCP service once its old stdio profile is replaced with a working endpoint.
## Verification log
**16 November 2026.** The release-readiness test run passed 17 checks and skipped
@@ -77,3 +87,11 @@ opt-in catalog download was skipped. Tests covered bounded UTF-8 file
previews, model-weight accounting, and rejection and idle eviction with a
live MLX model. Desktop and runtime implementation is complete. The final
external verification milestone remains.
**16 November 2026.** The workspace update built and launched. 36 tests
passed and the opt-in download was skipped. The installed Local Knowledge
server advertised search_knowledge using its LM Studio profile. Tests also
verified workspace backup and restore, web text extraction, performance
history encoding, and Return handling. The former Gitea stdio script is
missing; the separate GiteaMCP project speaks Streamable HTTP. The workspace
follow-up checklist tracks the remaining reference-app features.