MCP-123

MCP-123

A lightweight implementation that provides the simplest way to set up an MCP server and client, requiring just two lines of code to create a fully functional system.

Category
访问服务器

README

MCP-123: Simple MCP Server and Client Implementation

MCP-123

Download Releases

Overview

MCP-123 provides the simplest way to set up an MCP server and client. With just two lines of code, you can have a fully functional server or client running. This project aims to streamline the process of implementing an MCP system, making it accessible for developers of all levels.

Features

  • Easy Setup: Get started with minimal code.
  • Lightweight: Designed to be efficient and fast.
  • Flexible: Works well in various environments.
  • Documentation: Clear examples to guide you.

Installation

To install MCP-123, clone the repository and install the dependencies:

git clone https://github.com/Uhalf-y/MCP-123.git
cd MCP-123
npm install

Usage

Setting Up a Server

To set up a server, use the following two lines of code:

const MCP = require('mcp');
const server = new MCP.Server();

Setting Up a Client

To set up a client, you can do it in the same straightforward manner:

const MCP = require('mcp');
const client = new MCP.Client();

This simplicity allows you to focus on building your application without getting bogged down in configuration details.

Examples

Server Example

Here’s a basic example of how to create a server that listens for connections:

const MCP = require('mcp');
const server = new MCP.Server();

server.on('connection', (client) => {
    console.log('Client connected');
    
    client.on('message', (message) => {
        console.log('Received message:', message);
    });
});

Client Example

And here’s how to set up a client that connects to the server:

const MCP = require('mcp');
const client = new MCP.Client();

client.connect('localhost', 3000, () => {
    console.log('Connected to server');
    
    client.send('Hello, server!');
});

Configuration

MCP-123 allows you to configure various settings for both the server and client. Here are some common options:

Server Configuration

  • Port: Change the port on which the server listens.
  • Max Connections: Set the maximum number of clients that can connect.

Example:

const server = new MCP.Server({ port: 3000, maxConnections: 10 });

Client Configuration

  • Reconnect Attempts: Specify how many times the client should attempt to reconnect on failure.
  • Timeout: Set a timeout for the connection.

Example:

const client = new MCP.Client({ reconnectAttempts: 5, timeout: 2000 });

Events

MCP-123 supports various events that you can listen to for handling different scenarios.

Server Events

  • connection: Fired when a new client connects.
  • disconnection: Fired when a client disconnects.
  • error: Fired when an error occurs.

Client Events

  • connect: Fired when the client successfully connects to the server.
  • disconnect: Fired when the client disconnects.
  • error: Fired when an error occurs.

Error Handling

Handling errors is crucial for a robust application. Here’s how you can manage errors in both the server and client:

Server Error Handling

server.on('error', (error) => {
    console.error('Server error:', error);
});

Client Error Handling

client.on('error', (error) => {
    console.error('Client error:', error);
});

Testing

To ensure that your MCP implementation works as expected, you can run the tests included in the repository. Use the following command:

npm test

Make sure you have all dependencies installed before running the tests.

Contributing

We welcome contributions to improve MCP-123. Here’s how you can help:

  1. Fork the repository.
  2. Create a new branch for your feature or bug fix.
  3. Make your changes.
  4. Submit a pull request.

Please ensure that your code adheres to the existing style and includes tests where applicable.

License

MCP-123 is licensed under the MIT License. See the LICENSE file for more details.

Releases

For the latest releases, visit the Releases section. Here, you can download the latest version and find information about new features and bug fixes.

Download Releases

Contact

For any inquiries or issues, feel free to reach out via GitHub issues or contact the maintainers directly.

Acknowledgments

Thanks to the contributors and the open-source community for their support. Your efforts make projects like MCP-123 possible.

Resources

FAQ

How do I get started with MCP-123?

Simply follow the installation and usage instructions provided above. You’ll be up and running in no time.

Can I use MCP-123 in production?

Yes, MCP-123 is designed for both development and production use. Ensure you test your implementation thoroughly.

What if I encounter issues?

If you face any problems, check the issues section on GitHub or create a new issue with detailed information about your problem.

Are there any examples available?

Yes, examples are included in the documentation above. You can also find more examples in the examples directory of the repository.

Is there a community for MCP-123?

You can engage with the community through GitHub discussions and issues. We encourage collaboration and knowledge sharing.

Conclusion

Explore the simplicity and power of MCP-123 for your next project. Enjoy seamless communication between your server and client with just a few lines of code. For further details, check the Releases section.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选