MCP Server
Model Context Protocol server documentation
MCP Server
kinetic-context exposes a Model Context Protocol (MCP) server that AI coding tools can connect to for asking usage questions about dependencies.
What is kinetic-context?
kinetic-context is designed to help AI agents answer questions about how to use dependencies by analyzing their source code. It's not for querying dependency metadata (like package.json contents), but rather for asking questions like:
- "How do I validate forms with zod?"
- "What's the best way to use react-hook-form with TypeScript?"
- "How do I integrate zod with react-hook-form?"
The system clones dependency repositories and uses OpenCode to analyze the actual source code and provide intelligent answers based on the implementation.
What is MCP?
The Model Context Protocol (MCP) is a protocol that enables AI assistants to securely access external data sources and tools. kinetic-context implements an MCP server that provides information about open-source dependencies by analyzing their source code.
Server Endpoint
The MCP server is exposed at:
http://localhost:7167/mcp
(Or whatever port you've configured in your Docker Compose setup)
Available Tools
The MCP server provides the following tools:
list_project_dependencies
Lists all dependencies configured for a specific project. These dependencies can then be queried using query_dependency to ask usage questions about how to use them.
Parameters:
project_identifier(required): The identifier of the project (must match a project config file name)
Returns: Array of dependency objects with their identifiers and tags
Example:
{
"project_identifier": "my-project"
}Note: This tool lists which dependencies are configured for a project. To ask questions about how to use these dependencies, use query_dependency instead.
list_dependencies
Lists all available dependencies that have been configured in the system. These dependencies can then be queried using query_dependency to ask usage questions about how to use them.
Parameters: None
Returns: Array of all package identifiers with their display names and package managers
Use case: AI agents can use this to:
- See what dependencies are available to ask questions about
- Inform users if they want to ask about a dependency that isn't configured for their project
- Get the correct package identifier to use with
query_dependency
query_dependency
Ask questions about how to use a dependency. This tool analyzes the dependency's source code using OpenCode to provide intelligent answers about usage patterns, APIs, and best practices.
Important: This tool is for asking usage questions (e.g., "How do I validate forms with zod?"), not for querying dependency metadata (like package.json contents). The system analyzes the actual source code of the dependency to answer your questions.
Parameters:
dependency_identifier(required): The identifier of the dependency to query (uselist_dependenciesto find the correct identifier)query(required): The question to ask about how to use the dependencyproject_identifier(optional): If provided, the system will checkout the specific tag configured for this project before queryingsessionId(optional): Session ID to continue a previous conversation. If provided, the query will be added to the existing session, allowing for follow-up questions and conversation continuity.timeout(optional): Timeout in seconds. Default is 180 (3 minutes). Only set this if the user has agreed to a different timeout.
Returns: JSON object containing:
response: The answer to the query based on analysis of the dependency's source codesessionId: A session identifier that can be used in subsequent queries to continue the conversation
Example:
{
"dependency_identifier": "zod",
"query": "How do I validate an email address with zod?",
"project_identifier": "my-project",
"sessionId": "optional-session-id-from-previous-query"
}Example Response:
{
"response": "To validate an email address with zod, you can use the `z.string().email()` method:\n\n```typescript\nimport { z } from 'zod';\n\nconst emailSchema = z.string().email();\n\nconst result = emailSchema.parse('user@example.com');\n```\n\nThis will validate that the string is a valid email format according to RFC 5322.",
"sessionId": "abc123-session-id"
}Conversation Continuity: When you provide a sessionId from a previous query, the system maintains context from that conversation, allowing you to ask follow-up questions like "Can you show me an example?" or "What about validation for phone numbers?"
Multiple Dependencies: If you have questions about multiple dependencies, ask each question independently using separate query_dependency calls. For example, if you want to understand how zod and react-hook-form work together, you can:
- First ask
query_dependencyabout zod: "How do I create validation schemas with zod?" - Then ask
query_dependencyabout react-hook-form: "How do I integrate validation with react-hook-form?" - If needed, ask follow-up questions to either dependency using the same
sessionIdto maintain context
Connecting AI Tools
Claude Desktop
To connect Claude Desktop to kinetic-context:
- Open Claude Desktop settings
- Add a new MCP server
- Configure:
- Name: kinetic-context
- URL:
http://localhost:7167/mcp - Type: HTTP
Cursor
To connect Cursor to kinetic-context:
- Open Cursor settings
- Navigate to MCP servers
- Add configuration:
{ "name": "kinetic-context", "url": "http://localhost:7167/mcp" }
Custom Integration
You can integrate with any MCP-compatible client by pointing it to:
http://localhost:7167/mcpProject Identifier Matching
When using query_dependency with a project_identifier, the system will:
- Look up the project configuration
- Find the dependency in the project's dependencies list
- Checkout the specified tag (if different from default)
- Query the dependency at that specific version
This allows you to:
- Use different versions of the same dependency in different projects
- Pin specific versions for production
- Test with beta versions in experimental projects
How It Works
-
Package Cloning: When a dependency is first queried, kinetic-context clones the repository to
/packages/{identifier}/ -
Version Checkout: If a project identifier is provided and specifies a tag, the system checks out that specific tag
-
Code Analysis: OpenCode analyzes the dependency's codebase to understand its structure and usage
-
Query Processing: Your question is sent to OpenCode along with the relevant code context
-
Response: OpenCode provides an intelligent answer based on the actual code
Best Practices
-
Use project identifiers - Always specify
project_identifierwhen querying to ensure you get answers for the correct version -
Be specific in queries - More specific questions yield better answers (e.g., "How do I validate a form with zod?" vs. "How does zod work?")
-
Check available dependencies - Use
list_dependenciesfirst to see what's available -
Configure packages first - Make sure packages are configured before querying them
Troubleshooting
Connection Refused
Make sure kinetic-context is running:
kctx statusDependency Not Found
- Verify the dependency is configured in
/packages/{identifier}.json - Check that the repository can be cloned
- Ensure the identifier matches exactly
Wrong Version
- Check the project configuration for the dependency tag
- Verify the tag exists in the repository
- Try querying without
project_identifierto use the default tag
OpenCode Errors
Check the OpenCode configuration and API key in ~/.kctx/opencode/config/opencode.json